[wp-trac] [WordPress Trac] #53765: Media Library shows only the selected image
WordPress Trac
noreply at wordpress.org
Tue Nov 16 13:21:09 UTC 2021
#53765: Media Library shows only the selected image
------------------------------+-------------------------
Reporter: benitolopez | Owner: joedolson
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.9
Component: Media | Version: 5.8
Severity: normal | Resolution: fixed
Keywords: has-patch commit | Focuses: javascript
------------------------------+-------------------------
Comment (by szaqal21):
There's an update needed, after some more tests I've found some
optimizations and one bug in my approach. wp.media.view.Attachments view
calls scroll() on ready() if infinite scroll is enabled:
{{{
ready: function() {
if ( this.options.infiniteScrolling ) {
this.scroll();
}
},
}}}
so updateSelection() of wp.media.controller.ReplaceImage and
wp.media.controller.FeaturedImage should be updated to conditionally call
more() (only when infinite scroll if disabled):
FeaturedImage
{{{
updateSelection: function() {
var selection = this.get('selection'),
library = this.get('library'),
id = wp.media.view.settings.post.featuredImageId,
infinite_scrolling =
wp.media.view.settings.infiniteScrolling,
attachment;
if ( '' !== id && -1 !== id ) {
attachment = Attachment.get( id );
attachment.fetch();
}
selection.reset( attachment ? [ attachment ] : [] );
if ( ! infinite_scrolling && library.hasMore() ) {
library.more();
}
}
}}}
and ReplaceImage
{{{
updateSelection: function() {
var selection = this.get('selection'),
library = this.get('library'),
infinite_scrolling =
wp.media.view.settings.infiniteScrolling,
attachment = this.image.attachment;
selection.reset( attachment ? [ attachment ] : [] );
if ( ! infinite_scrolling && library.getTotalAttachments()
== 0 && library.hasMore() ) {
library.more();
}
}
}}}
there's library.getTotalAttachments() == 0 check in updateSelection() of
ReplaceImage controller because activate() is being called every time user
hits Replace button in edit image view if user would hit Replace button
then hit Back and again hit Replace he would get another portion of
attachments loaded.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53765#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list