diff options
author | Adam Silverstein <adamsilverstein@git.wordpress.org> | 2018-02-25 16:40:33 +0000 |
---|---|---|
committer | Adam Silverstein <adamsilverstein@git.wordpress.org> | 2018-02-25 16:40:33 +0000 |
commit | c84a3d2df0fd2a98f901677044ab5796848460a0 (patch) | |
tree | fdcd022b17da4958b699c05493149dc164b7bc7f /src/wp-includes/js | |
parent | 32f5aacba77be0fa509537602ecea94ec9e14a3c (diff) | |
download | wordpress-c84a3d2df0fd2a98f901677044ab5796848460a0.tar.gz wordpress-c84a3d2df0fd2a98f901677044ab5796848460a0.zip |
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
Diffstat (limited to 'src/wp-includes/js')
-rw-r--r-- | src/wp-includes/js/media-models.js | 9 | ||||
-rw-r--r-- | src/wp-includes/js/media-views.js | 15 | ||||
-rw-r--r-- | src/wp-includes/js/media/controllers/library.js | 15 | ||||
-rw-r--r-- | src/wp-includes/js/media/models/attachments.js | 9 |
4 files changed, 18 insertions, 30 deletions
diff --git a/src/wp-includes/js/media-models.js b/src/wp-includes/js/media-models.js index af64387257..28caa1553a 100644 --- a/src/wp-includes/js/media-models.js +++ b/src/wp-includes/js/media-models.js @@ -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; } diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 5b10a05d5f..bd1798bd4d 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -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. diff --git a/src/wp-includes/js/media/controllers/library.js b/src/wp-includes/js/media/controllers/library.js index 6f30cbb354..0422572c68 100644 --- a/src/wp-includes/js/media/controllers/library.js +++ b/src/wp-includes/js/media/controllers/library.js @@ -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. diff --git a/src/wp-includes/js/media/models/attachments.js b/src/wp-includes/js/media/models/attachments.js index c76bbbdfac..06510ef9fc 100644 --- a/src/wp-includes/js/media/models/attachments.js +++ b/src/wp-includes/js/media/models/attachments.js @@ -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; } |