In `wp.media.model.Attachments.filters.type()`, return `true` earlier if `type` isn't set.

Props vivekbhusal.
Fixes #32746.


git-svn-id: https://develop.svn.wordpress.org/trunk@33091 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-07-06 15:33:53 +00:00
parent 345521666e
commit 3eaaa104b5
2 changed files with 12 additions and 4 deletions

View File

@ -897,14 +897,18 @@ var Attachments = Backbone.Collection.extend({
type: function( attachment ) {
var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
if ( ! type || ( _.isArray( type ) && ! type.length ) ) {
return true;
}
mime = atts.mime || ( atts.file && atts.file.type ) || '';
if ( _.isArray( type ) ) {
found = ! type.length || _.find( type, function (t) {
found = _.find( type, function (t) {
return -1 !== mime.indexOf( t );
} );
} else {
found = ! type || -1 !== mime.indexOf( type );
found = -1 !== mime.indexOf( type );
}
return found;

View File

@ -493,14 +493,18 @@ var Attachments = Backbone.Collection.extend({
type: function( attachment ) {
var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
if ( ! type || ( _.isArray( type ) && ! type.length ) ) {
return true;
}
mime = atts.mime || ( atts.file && atts.file.type ) || '';
if ( _.isArray( type ) ) {
found = ! type.length || _.find( type, function (t) {
found = _.find( type, function (t) {
return -1 !== mime.indexOf( t );
} );
} else {
found = ! type || -1 !== mime.indexOf( type );
found = -1 !== mime.indexOf( type );
}
return found;