WordPress.org

Make WordPress Core

Ticket #42968: 42968.3.diff

File 42968.3.diff, 3.2 KB (added by adamsilverstein, 17 months ago)
  • src/wp-includes/js/media-models.js

    diff --git src/wp-includes/js/media-models.js src/wp-includes/js/media-models.js
    index af64387257..28caa1553a 100644
    var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen 
    642642         * @returns {Boolean}
    643643         */
    644644        validator: function( attachment ) {
     645
     646                // Filter out contextually created attachments (e.g. headers, logos, etc.).
     647                if (
     648                        ! _.isUndefined( attachment.attributes.context ) &&
     649                        '' !== attachment.attributes.context
     650                ) {
     651                        return false;
     652                }
     653
    645654                if ( ! this.validateDestroyed && attachment.destroyed ) {
    646655                        return false;
    647656                }
  • src/wp-includes/js/media-views.js

    diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
    index 3287b73762..ee4905aeb6 100644
    Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar 
    953953                        }) );
    954954                }
    955955
    956                 this._filterContext();
    957                 this.get('library').on( 'add', this._filterContext, this );
    958 
    959956                this.resetDisplays();
    960957        },
    961958
    Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar 
    11571154                }
    11581155        },
    11591156
    1160         /**
    1161          * Filter out contextually created attachments (e.g. headers, logos, etc.)
    1162          *
    1163          * @since 4.9.0
    1164          */
    1165         _filterContext: function() {
    1166                 var library = this.get('library');
    1167 
    1168                 library.set( library.filter( function( item ) {
    1169                         return item.get('context') === '';
    1170                 } ) );
    1171         }
    11721157});
    11731158
    11741159// Make selectionSync available on any Media Library state.
  • src/wp-includes/js/media/controllers/library.js

    diff --git src/wp-includes/js/media/controllers/library.js src/wp-includes/js/media/controllers/library.js
    index 6f30cbb354..0422572c68 100644
    Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar 
    8585                        }) );
    8686                }
    8787
    88                 this._filterContext();
    89                 this.get('library').on( 'add', this._filterContext, this );
    90 
    9188                this.resetDisplays();
    9289        },
    9390
    Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar 
    289286                }
    290287        },
    291288
    292         /**
    293          * Filter out contextually created attachments (e.g. headers, logos, etc.)
    294          *
    295          * @since 4.9.0
    296          */
    297         _filterContext: function() {
    298                 var library = this.get('library');
    299 
    300                 library.set( library.filter( function( item ) {
    301                         return item.get('context') === '';
    302                 } ) );
    303         }
    304289});
    305290
    306291// Make selectionSync available on any Media Library state.
  • src/wp-includes/js/media/models/attachments.js

    diff --git src/wp-includes/js/media/models/attachments.js src/wp-includes/js/media/models/attachments.js
    index c76bbbdfac..06510ef9fc 100644
    var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen 
    151151         * @returns {Boolean}
    152152         */
    153153        validator: function( attachment ) {
     154
     155                // Filter out contextually created attachments (e.g. headers, logos, etc.).
     156                if (
     157                        ! _.isUndefined( attachment.attributes.context ) &&
     158                        '' !== attachment.attributes.context
     159                ) {
     160                        return false;
     161                }
     162
    154163                if ( ! this.validateDestroyed && attachment.destroyed ) {
    155164                        return false;
    156165                }