My WordPress site is fairly large. It's being used as a blog and a CMS, with a WooCommerce shop running off it as well. There's probably over 2000 images in the media library at this stage.

My problem is whenever new images need to be added to a post or a product, it's glacially slow.

I have disabled every plugin on the website on a test deployment. The media library is still incredibly slow. I've also checked it isn't loading full size images, it appears to be loading the 300x300 medium images.

Generally the site has acceptable load times for pages and in the admin. They could be quicker, but they aren't more than a second or two for the worst pages.

I think the main issue is whenever the add media button is clicked, the library loads every image ever put on the site. List view is much, much quicker. But this type of view isn't available when adding an image in a post - or when uploading a new product image, it defaults to the thumbnails that show all images.

What can I do to speed up the media library?

  • Does your server send appropriate cache headers (expires or max-age) for the images, so that browsers can cache the thumbnails? Typically the WordPress media grid »paginates« the query for the attachments (here to 40 images per query) and loads the next 40 images when you scroll to the bottom of the grid. Another option would be to set the default view to »Uploaded to this post«: wordpress.org/plugins/default-media-uploader-view
    – David
    Apr 5, 2016 at 7:59

1 Answer 1


I'm copying a previous answer here as I think it will help. What this will do is whenever the media library pops up, instead of showing all media for a given post it will filter down to only images attached to the post. You could paste this right into your functions file:

 * Media Module - Only Show Images Uploaded To this Post
function wpse222583_media_library_filter() { 
      <script type="text/javascript">
        jQuery( document ).on( 'DOMNodeInserted', function() {
            jQuery( 'select.attachment-filters [value="uploaded"]' ).attr( 'selected', true ).parent().trigger( 'change' );
        } );
add_action( 'admin_footer-post-new.php', 'wpse222583_media_library_filter' );
add_action( 'admin_footer-post.php', 'wpse222583_media_library_filter' );

The above doesn't remove the filter from the media module so if you need to see all the media you can just change the filter while in the admin panel, this just presets it to only show attached media.

Media Library Filter Dropdown List

If this doesn't work there's a ton of other answers to this older question which I feel is related.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.