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.


git-svn-id: https://develop.svn.wordpress.org/trunk@32915 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-06-23 19:39:21 +00:00
parent 6cded9493a
commit 75b6e0755d
2 changed files with 26 additions and 4 deletions

View File

@@ -895,8 +895,19 @@ var Attachments = Backbone.Collection.extend({
* @returns {Boolean}
*/
type: function( attachment ) {
var type = this.props.get('type');
return ! type || -1 !== type.indexOf( attachment.get('type') );
var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
mime = atts.mime || ( atts.file && atts.file.type ) || '';
if ( _.isArray( type ) ) {
found = _.find( type, function (t) {
return -1 !== mime.indexOf( t );
} );
} else {
found = ! type || -1 !== mime.indexOf( type );
}
return found;
},
/**
* @static

View File

@@ -491,8 +491,19 @@ var Attachments = Backbone.Collection.extend({
* @returns {Boolean}
*/
type: function( attachment ) {
var type = this.props.get('type');
return ! type || -1 !== type.indexOf( attachment.get('type') );
var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
mime = atts.mime || ( atts.file && atts.file.type ) || '';
if ( _.isArray( type ) ) {
found = _.find( type, function (t) {
return -1 !== mime.indexOf( t );
} );
} else {
found = ! type || -1 !== mime.indexOf( type );
}
return found;
},
/**
* @static