From 73ddcbda655c2b5ec67757d2a8592d4c8b91dbe9 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 30 Nov 2021 19:05:52 +0000 Subject: [PATCH] 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 --- src/js/media/controllers/featured-image.js | 3 ++- src/js/media/controllers/replace-image.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/media/controllers/featured-image.js b/src/js/media/controllers/featured-image.js index e05b377be3..5fd5797bd0 100644 --- a/src/js/media/controllers/featured-image.js +++ b/src/js/media/controllers/featured-image.js @@ -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(); } } diff --git a/src/js/media/controllers/replace-image.js b/src/js/media/controllers/replace-image.js index 858e84c2d5..c400d22b10 100644 --- a/src/js/media/controllers/replace-image.js +++ b/src/js/media/controllers/replace-image.js @@ -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(); } }