5 steps for Cleaning up your WordPress media library

Keep your site speed fast, and optimize your media library. I’ve seen it too many times! People keep uploading the same images every time they create sort of the same page. You should re-use the image that’s already there in that case. I’ve also seen plenty of times that there are many images that aren’t used anymore. Think about old images or product images from products that are already removed from the website.

When you delete a product from WooCommerce, it doesn’t delete its images!

In short, before you know it, your media library has its own will. Thankfully, we’ll be able to get back control.

Before we start, always make sure you make a backup from your website (including all the images and database).

Guide to optimizing and cleaning up the WordPress media library

Let’s get to it.

Step 1: Create a backup of the website, database, and make sure images are included

It speaks for itself, just in case something goes wrong with the steps below.

Step 2: Unused Images.

The first step is to see what images are and are not being used. You can do that with this plugin Media Cleaner.

This plugin looks at whether images are being used or not. From there on, you can delete the ones that are not being used.

Plugin description
Media Cleaner cleans your Media Library from the media entries (and files) which aren’t used in your website, as well as broken entries. Internal rubbish allows you to make sure everything works properly before deleting the media entries (and files) permanently. It uses a smart analysis powered by many implementations for specific plugins and themes.

Step 3: Duplicated images

The next step is to look for duplicate images. Duplicate images mean images from which there are more than 1. We’ll use another plugin called Media Deduper. I highly recommend using the pro version ($25,-) to make sure you don’t delete the wrong images! The pro version has some advantages. If you don’t use the pro version, try this whole process on a test/staging environment first.

This plugin looks at whether an image appears multiple times in the media library. If that is the case, you can delete it. If the image being removed has been used, the plugin will automatically replace it with the original version of the image.

Plugin Description:

Media Deduper will find and eliminate duplicate images and attachments from your WordPress media library. After installing, you’ll have a new “Manage Duplicates” option in your Media section.

Before Media Deduper can identify duplicate assets, it will build an index of all the files in your media library, which can take some time. Once that’s done, however, Media Deduper automatically adds new uploads to its index, so you shouldn’t have to generate the index again.

Once up and running, Media Deduper provides two key tools:

  1. A “Manage Duplicates” page listing all of your duplicate media files. The list makes it easy to see and delete duplicate files: delete one and its twin will disappear from the list because it’s then no longer a duplicate. Easy! By default, the list is sorted by file size, so you can focus on deleting the files that will free up the most space.
  2. A scan of media files as they’re uploaded via the admin to prevent a duplicate from being added to your Media Library. Prevents new duplicates from being introduced, automagically!

Media Deduper comes with a “Smart Delete” option that prevents a post’s Featured Image from being deleted, even if that image is found to be a duplicate elsewhere on the site.

If a post has a featured image that’s a duplicate file, Smart Delete will re-assign that post’s image to an already-in-use copy of the image before deleting the duplicate so that the post’s appearance is unaffected. This feature only tracks Featured Images and not images used in galleries, post bodies, shortcodes, meta fields, or anywhere else.

Step 4: Optimizing images (Optional)

We’ve optimized the media library. It might be smart to re-optimize all the images again, just to be sure it’s all optimized. There are plenty of free/paid plugins to optimize your images like Smush, EWWW Image Optimizer, and Imagify.

Step 5: Remove Media Cleaner and Media Deduper

Remove the plugins, they are no longer of value and might make the website slower.


I hope this simple guide will have you move forward and helps to improve your awesome website. It will decrease the space on the server, it will make the website faster, and it will make the media library more efficient for you.

If there is anything missing in this guide, please kindly send me the details and I will update this post.

Logo Freelance CRO specialist Sander Volbeda

Working remotely from Groningen, the Netherlands. Get in touch and let’s schedule a meeting, no strings attached.

Get in touch
© 2024 Sander Volbeda, All rights reserved
CoC: 53236734 VAT: NL002247968B39