Make WordPress Core

Changeset 42739


Ignore:
Timestamp:
02/25/2018 04:40:33 PM (8 years ago)
Author:
adamsilverstein
Message:

Media: grid view - correct placeholder positioning during uploads.

Preventing contextually created attachments from being added to the grid collection in Attachments.validator. Remove the previous filtering introduced in [41937] which caused the placement issue.

Props lancewillett, Junaidkbr, designsimply, joemcgill.
Fixes #42968.

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

Legend:

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

    r41752 r42739  
    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;
  • trunk/src/wp-includes/js/media-views.js

    r42709 r42739  
    954954                }
    955955
    956                 this._filterContext();
    957                 this.get('library').on( 'add', this._filterContext, this );
    958 
    959956                this.resetDisplays();
    960957        },
     
    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
  • trunk/src/wp-includes/js/media/controllers/library.js

    r41937 r42739  
    8686                }
    8787
    88                 this._filterContext();
    89                 this.get('library').on( 'add', this._filterContext, this );
    90 
    9188                this.resetDisplays();
    9289        },
     
    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
  • trunk/src/wp-includes/js/media/models/attachments.js

    r41351 r42739  
    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;
Note: See TracChangeset for help on using the changeset viewer.