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.


git-svn-id: https://develop.svn.wordpress.org/trunk@42739 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Adam Silverstein 2018-02-25 16:40:33 +00:00
parent 32f5aacba7
commit c84a3d2df0
4 changed files with 18 additions and 30 deletions

View File

@ -642,6 +642,15 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
* @returns {Boolean}
*/
validator: function( attachment ) {
// Filter out contextually created attachments (e.g. headers, logos, etc.).
if (
! _.isUndefined( attachment.attributes.context ) &&
'' !== attachment.attributes.context
) {
return false;
}
if ( ! this.validateDestroyed && attachment.destroyed ) {
return false;
}

View File

@ -953,9 +953,6 @@ Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar
}) );
}
this._filterContext();
this.get('library').on( 'add', this._filterContext, this );
this.resetDisplays();
},
@ -1157,18 +1154,6 @@ Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar
}
},
/**
* Filter out contextually created attachments (e.g. headers, logos, etc.)
*
* @since 4.9.0
*/
_filterContext: function() {
var library = this.get('library');
library.set( library.filter( function( item ) {
return item.get('context') === '';
} ) );
}
});
// Make selectionSync available on any Media Library state.

View File

@ -85,9 +85,6 @@ Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar
}) );
}
this._filterContext();
this.get('library').on( 'add', this._filterContext, this );
this.resetDisplays();
},
@ -289,18 +286,6 @@ Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar
}
},
/**
* Filter out contextually created attachments (e.g. headers, logos, etc.)
*
* @since 4.9.0
*/
_filterContext: function() {
var library = this.get('library');
library.set( library.filter( function( item ) {
return item.get('context') === '';
} ) );
}
});
// Make selectionSync available on any Media Library state.

View File

@ -151,6 +151,15 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
* @returns {Boolean}
*/
validator: function( attachment ) {
// Filter out contextually created attachments (e.g. headers, logos, etc.).
if (
! _.isUndefined( attachment.attributes.context ) &&
'' !== attachment.attributes.context
) {
return false;
}
if ( ! this.validateDestroyed && attachment.destroyed ) {
return false;
}