diff --git src/wp-includes/js/media-models.js src/wp-includes/js/media-models.js
index af64387257..6884c5a4f5 100644
|
|
var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen |
642 | 642 | * @returns {Boolean} |
643 | 643 | */ |
644 | 644 | validator: function( attachment ) { |
| 645 | |
| 646 | // Filter out contextually created attachments (e.g. headers, logos, etc.). |
| 647 | if ( '' !== attachment.attributes.context ) { |
| 648 | return false; |
| 649 | } |
| 650 | |
645 | 651 | if ( ! this.validateDestroyed && attachment.destroyed ) { |
646 | 652 | return false; |
647 | 653 | } |
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 |
953 | 953 | }) ); |
954 | 954 | } |
955 | 955 | |
956 | | this._filterContext(); |
957 | | this.get('library').on( 'add', this._filterContext, this ); |
958 | | |
959 | 956 | this.resetDisplays(); |
960 | 957 | }, |
961 | 958 | |
… |
… |
Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar |
1157 | 1154 | } |
1158 | 1155 | }, |
1159 | 1156 | |
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 | | } |
1172 | 1157 | }); |
1173 | 1158 | |
1174 | 1159 | // Make selectionSync available on any Media Library state. |
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 |
85 | 85 | }) ); |
86 | 86 | } |
87 | 87 | |
88 | | this._filterContext(); |
89 | | this.get('library').on( 'add', this._filterContext, this ); |
90 | | |
91 | 88 | this.resetDisplays(); |
92 | 89 | }, |
93 | 90 | |
… |
… |
Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar |
289 | 286 | } |
290 | 287 | }, |
291 | 288 | |
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 | | } |
304 | 289 | }); |
305 | 290 | |
306 | 291 | // Make selectionSync available on any Media Library state. |
diff --git src/wp-includes/js/media/models/attachments.js src/wp-includes/js/media/models/attachments.js
index c76bbbdfac..80a726f6a2 100644
|
|
var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen |
151 | 151 | * @returns {Boolean} |
152 | 152 | */ |
153 | 153 | validator: function( attachment ) { |
| 154 | |
| 155 | // Filter out contextually created attachments (e.g. headers, logos, etc.). |
| 156 | if ( '' !== attachment.attributes.context ) { |
| 157 | return false; |
| 158 | } |
| 159 | |
154 | 160 | if ( ! this.validateDestroyed && attachment.destroyed ) { |
155 | 161 | return false; |
156 | 162 | } |