diff --git a/src/wp-includes/js/media-models.js b/src/wp-includes/js/media-models.js index d55d152aad..27b7c69f23 100644 --- a/src/wp-includes/js/media-models.js +++ b/src/wp-includes/js/media-models.js @@ -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; diff --git a/src/wp-includes/js/media/models/attachments.js b/src/wp-includes/js/media/models/attachments.js index 2cc3b6a421..7a0751722b 100644 --- a/src/wp-includes/js/media/models/attachments.js +++ b/src/wp-includes/js/media/models/attachments.js @@ -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;