Media: Featured image modal loads only selected image.

Fix bug introduced in [50829] that caused media modal to only load the selected image. Executes `.more()` when loading the modal to ensure that the media collection is available.

Props benitolopez, hellofromTonya, peterwilsoncc, danielbachhuber, PieWP, sabernhardt, szaqal21.
Fixes #53765.

git-svn-id: https://develop.svn.wordpress.org/trunk@52167 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson 2021-11-15 20:53:08 +00:00
parent 1fcde43588
commit 2049f04b4d
2 changed files with 10 additions and 1 deletions

View File

@ -87,7 +87,6 @@ FeaturedImage = Library.extend(/** @lends wp.media.controller.FeaturedImage.prot
* @since 3.5.0
*/
activate: function() {
this.updateSelection();
this.frame.on( 'open', this.updateSelection, this );
Library.prototype.activate.apply( this, arguments );
@ -107,6 +106,7 @@ FeaturedImage = Library.extend(/** @lends wp.media.controller.FeaturedImage.prot
*/
updateSelection: function() {
var selection = this.get('selection'),
library = this.get('library'),
id = wp.media.view.settings.post.featuredImageId,
attachment;
@ -116,6 +116,10 @@ FeaturedImage = Library.extend(/** @lends wp.media.controller.FeaturedImage.prot
}
selection.reset( attachment ? [ attachment ] : [] );
if ( library.hasMore() ) {
library.more();
}
}
});

View File

@ -99,9 +99,14 @@ ReplaceImage = Library.extend(/** @lends wp.media.controller.ReplaceImage.protot
*/
updateSelection: function() {
var selection = this.get('selection'),
library = this.get('library'),
attachment = this.image.attachment;
selection.reset( attachment ? [ attachment ] : [] );
if ( library.hasMore() ) {
library.more();
}
}
});