Over time, the media gallery gets heavier and heavier. I noticed that in admin-ajax.php the wp brings 40 images in a single query, it is taking too long to render the images on the screen, sometimes more than 50 seconds.
How could you reduce these consultations to 10? And when scrolling, continue loading the other images every 10
I found this piece of code
add_filter ('ajax_query_attachments_args', function ($ query) { $ query ['number_posts'] = 10 return $ query; });
However, it only lists the first 10 images and I can't see the rest, it doesn't have a page or scroll.
There is already a whole job of optimizing the image
Print: .png