Media: Use infiniteScrolling global setting in js/media/controllers/featured-image.js and js/media/controllers/replace-image.js.

Follow-up to [52287] which added an undefined variable. The variable should have been the global `wp.media.view.settings.infiniteScrolling`. This commit brings that global setting into each of the functions and renames the variable using camelCase to comply with JS coding standards.

Follow-up to [52287].

Props SergeyBiryukov.
Fixes #53765.

git-svn-id: https://develop.svn.wordpress.org/trunk@52288 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork 2021-11-30 19:05:52 +00:00
parent aaded1d17e
commit 73ddcbda65
2 changed files with 5 additions and 3 deletions

View File

@ -108,6 +108,7 @@ FeaturedImage = Library.extend(/** @lends wp.media.controller.FeaturedImage.prot
var selection = this.get('selection'),
library = this.get('library'),
id = wp.media.view.settings.post.featuredImageId,
infiniteScrolling = wp.media.view.settings.infiniteScrolling,
attachment;
if ( '' !== id && -1 !== id ) {
@ -117,7 +118,7 @@ FeaturedImage = Library.extend(/** @lends wp.media.controller.FeaturedImage.prot
selection.reset( attachment ? [ attachment ] : [] );
if ( ! infinite_scrolling && library.hasMore() ) {
if ( ! infiniteScrolling && library.hasMore() ) {
library.more();
}
}

View File

@ -100,11 +100,12 @@ ReplaceImage = Library.extend(/** @lends wp.media.controller.ReplaceImage.protot
updateSelection: function() {
var selection = this.get('selection'),
library = this.get('library'),
attachment = this.image.attachment;
attachment = this.image.attachment,
infiniteScrolling = wp.media.view.settings.infiniteScrolling;
selection.reset( attachment ? [ attachment ] : [] );
if ( ! infinite_scrolling && library.getTotalAttachments() == 0 && library.hasMore() ) {
if ( ! infiniteScrolling && library.getTotalAttachments() === 0 && library.hasMore() ) {
library.more();
}
}