Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/js/media/models/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
* @readonly
*/
defaultArgs: {
posts_per_page: 80
posts_per_page: 40
},
/**
* @readonly
Expand Down Expand Up @@ -281,6 +281,11 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
// Fill any other default query args.
_.defaults( args, Query.defaultArgs );

// When 'Load more' is enabled, increase the posts pr page to 80.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid catch

if ( wp.media && wp.media.view && wp.media.view.settings && wp.media.view.settings.infiniteScrolling === 0 ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should use ! wp.media.view.settings.infiniteScrolling instead of wp.media.view.settings.infiniteScrolling === 0 to match the existing convention as the rest of the UI.

args.posts_per_page = 80;
}
Comment on lines +285 to +287

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this point is valid. For example, the media gallery applies perPage-1, which could unintentionally overwrite this.

Furthermore, I believe that checking for infiniteScrolling === 0 is too strict. This is because it may lead to mismatches if media_view_settings filters set the value to false or "0", as these do not align with the strict equality check. See https://github.com/t-hamano/wordpress-develop/blob/57b8740a0a9b0f65333ff0b6aaa9c5ff66232f89/src/js/media/views/attachments/browser.js#L80

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second this. It's very important to preserve any perPage / posts_per_page that override the defaults.


// `props.orderby` does not always map directly to `args.orderby`.
// Substitute exceptions specified in orderby.keymap.
args.orderby = orderby.valuemap[ props.orderby ] || props.orderby;
Expand Down
Loading