mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user