Make WordPress Core

Changeset 32915


Ignore:
Timestamp:
06/23/2015 07:39:21 PM (10 years ago)
Author:
wonderboymusic
Message:

When filtering media by type in wp.media.model.Attachments.filters.type(), account for the library's type being an array of full mime-types.

Fixes #32746.

Location:
trunk/src/wp-includes/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-models.js

    r32125 r32915  
    896896         */
    897897        type: function( attachment ) {
    898             var type = this.props.get('type');
    899             return ! type || -1 !== type.indexOf( attachment.get('type') );
     898            var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
     899
     900            mime = atts.mime || ( atts.file && atts.file.type ) || '';
     901
     902            if ( _.isArray( type ) ) {
     903                found = _.find( type, function (t) {
     904                    return -1 !== mime.indexOf( t );
     905                } );
     906            } else {
     907                found = ! type || -1 !== mime.indexOf( type );
     908            }
     909
     910            return found;
    900911        },
    901912        /**
  • trunk/src/wp-includes/js/media/models/attachments.js

    r31935 r32915  
    492492         */
    493493        type: function( attachment ) {
    494             var type = this.props.get('type');
    495             return ! type || -1 !== type.indexOf( attachment.get('type') );
     494            var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
     495
     496            mime = atts.mime || ( atts.file && atts.file.type ) || '';
     497
     498            if ( _.isArray( type ) ) {
     499                found = _.find( type, function (t) {
     500                    return -1 !== mime.indexOf( t );
     501                } );
     502            } else {
     503                found = ! type || -1 !== mime.indexOf( type );
     504            }
     505
     506            return found;
    496507        },
    497508        /**
Note: See TracChangeset for help on using the changeset viewer.