0

I have a project with a quite extensive Media Library. Everytime an admin user gets into the Media Library it ends up making several hundreds of requests, as per default it progressively lazy loads everything.

I have all media content hosted in AWS S3, and I would like to restrict the numbers of requests to keep request quotas controlled, as well as relieving a bit the browser's request stack. People who will use the backend has to upload generous amounts of media, and making those many hunderds of requests just in the few first seconds every user gets into Media Library seems nonsense for me.

The behavior I'm looking for is to trigger the next lazy load on demand by an user action (such as scrolling to the bottom of the media grid), or having some sort of user-controlled pagination where the media content per page can be limited to a safe controlled amount.

I haven't found any information on the WP Codex about how to do that, except the upload_per_page hook, but I think this just limits how many items are requested on every lazy load.

  • If possible I want to take control of this by modifying functions.php, or making my own plugin if necessary.

  • It needs to be mostly a server-side solution, so JS hacky solutions are not what I'm looking for.

  • I don't want to install any third-party plugin that magically does what I'm trying to do (I like to control my own code and keep plugins at the bare minimum necessary), but if there's any plugin that applies that behavior I'd be thankful to have some references about it and study its source code.

Any ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.