]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/media-models.js
WordPress 4.7
[autoinstalls/wordpress.git] / wp-includes / js / media-models.js
index 4bc7f61c6538a7c7712c90392769c28d7a1889e6..f5683a939e305de7aad74f3c08d5d10c4f20dab5 100644 (file)
@@ -1,6 +1,4 @@
 (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
 var $ = jQuery,
        Attachment, Attachments, l10n, media;
 
@@ -232,8 +230,6 @@ $(window).on('unload', function(){
 });
 
 },{"./models/attachment.js":2,"./models/attachments.js":3,"./models/post-image.js":4,"./models/query.js":5,"./models/selection.js":6}],2:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
 /**
  * wp.media.model.Attachment
  *
@@ -402,8 +398,6 @@ Attachment = Backbone.Model.extend({
 module.exports = Attachment;
 
 },{}],3:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
 /**
  * wp.media.model.Attachments
  *
@@ -702,7 +696,7 @@ var Attachments = Backbone.Collection.extend({
                delete this.mirroring;
        },
        /**
-        * Retrive more attachments from the server for the collection.
+        * Retrieve more attachments from the server for the collection.
         *
         * Only works if the collection is mirroring a Query Attachments collection,
         * and forwards to its `more` method. This collection class doesn't have
@@ -895,8 +889,23 @@ 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;
+
+                       if ( ! type || ( _.isArray( type ) && ! type.length ) ) {
+                               return true;
+                       }
+
+                       mime = atts.mime || ( atts.file && atts.file.type ) || '';
+
+                       if ( _.isArray( type ) ) {
+                               found = _.find( type, function (t) {
+                                       return -1 !== mime.indexOf( t );
+                               } );
+                       } else {
+                               found = -1 !== mime.indexOf( type );
+                       }
+
+                       return found;
                },
                /**
                 * @static
@@ -936,8 +945,6 @@ var Attachments = Backbone.Collection.extend({
 module.exports = Attachments;
 
 },{}],4:[function(require,module,exports){
-/*globals Backbone */
-
 /**
  * wp.media.model.PostImage
  *
@@ -1092,8 +1099,6 @@ var PostImage = Backbone.Model.extend({
 module.exports = PostImage;
 
 },{}],5:[function(require,module,exports){
-/*globals wp, _ */
-
 /**
  * wp.media.model.Query
  *
@@ -1402,8 +1407,6 @@ Query = Attachments.extend({
 module.exports = Query;
 
 },{}],6:[function(require,module,exports){
-/*globals wp, _ */
-
 /**
  * wp.media.model.Selection
  *