-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Set the media attachments query posts per page conditionally. #12838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,7 +171,7 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ | |
| * @readonly | ||
| */ | ||
| defaultArgs: { | ||
| posts_per_page: 80 | ||
| posts_per_page: 40 | ||
| }, | ||
| /** | ||
| * @readonly | ||
|
|
@@ -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. | ||
| if ( wp.media && wp.media.view && wp.media.view.settings && wp.media.view.settings.infiniteScrolling === 0 ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we should use |
||
| args.posts_per_page = 80; | ||
| } | ||
|
Comment on lines
+285
to
+287
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I second this. It's very important to preserve any |
||
|
|
||
| // `props.orderby` does not always map directly to `args.orderby`. | ||
| // Substitute exceptions specified in orderby.keymap. | ||
| args.orderby = orderby.valuemap[ props.orderby ] || props.orderby; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid catch