From 3eaaa104b5d94243ec5f6012a1a47142f5030149 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 6 Jul 2015 15:33:53 +0000 Subject: [PATCH] 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 --- src/wp-includes/js/media-models.js | 8 ++++++-- src/wp-includes/js/media/models/attachments.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) 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;