Make WordPress Core

Changeset 33091


Ignore:
Timestamp:
07/06/2015 03:33:53 PM (9 years ago)
Author:
wonderboymusic
Message:

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

Props vivekbhusal.
Fixes #32746.

Location:
trunk/src/wp-includes/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-models.js

    r32916 r33091  
    898898            var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
    899899
     900            if ( ! type || ( _.isArray( type ) && ! type.length ) ) {
     901                return true;
     902            }
     903
    900904            mime = atts.mime || ( atts.file && atts.file.type ) || '';
    901905
    902906            if ( _.isArray( type ) ) {
    903                 found = ! type.length || _.find( type, function (t) {
     907                found = _.find( type, function (t) {
    904908                    return -1 !== mime.indexOf( t );
    905909                } );
    906910            } else {
    907                 found = ! type || -1 !== mime.indexOf( type );
     911                found = -1 !== mime.indexOf( type );
    908912            }
    909913
  • trunk/src/wp-includes/js/media/models/attachments.js

    r32916 r33091  
    494494            var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
    495495
     496            if ( ! type || ( _.isArray( type ) && ! type.length ) ) {
     497                return true;
     498            }
     499
    496500            mime = atts.mime || ( atts.file && atts.file.type ) || '';
    497501
    498502            if ( _.isArray( type ) ) {
    499                 found = ! type.length || _.find( type, function (t) {
     503                found = _.find( type, function (t) {
    500504                    return -1 !== mime.indexOf( t );
    501505                } );
    502506            } else {
    503                 found = ! type || -1 !== mime.indexOf( type );
     507                found = -1 !== mime.indexOf( type );
    504508            }
    505509
Note: See TracChangeset for help on using the changeset viewer.