Finding and Cleaning Unused Images in the Wordpress Media Library

This plugin does two things: scans your Wordpress media library for unused images and scans your uploads folder for images that aren’t in the media library.

Media Cleaner for Wordpress main panel
Text & Photos By David Coleman
Last Revised & Updated:

I MAY get commissions for purchases made through links in this post.

I converted this site to Wordpress in 2009. Since then, Wordpress has gone through a lot of changes. As has the site. Sections on some topics have been peeled off to their own sites. Some were later merged back in. It’s been moved several times to new hosts. And many thousands of images have been added and new thumbnail sizes incorporated as I’ve upgraded themes.

All of that has taken a toll on the Media Library. It became cluttered with images that were no longer being used in posts, and there were remnants of different parts of the site that were in the uploads folder but weren’t showing up in the Media Library.

In short, the Media Library had become a bit of a mess. And all that extra bloat meant using more disk space and slower site backups.

So I’ve been doing some spring cleaning. For the Media Library I’ve been using the Media Cleaner plugin by Jordy Meow. Probably his best-known plugin is the WP Retina 2x plugin, which serves high-density Retina images to the new generation of displays that can use them. I’ve also written about his Lightroom to Wordpress publish service plugin.

What It Does

Media Cleaner has two operations it can do, and you can run each independently. Please note that both of these have the potentially to really screw up your site, so it’s one of those plugins that should be used with a lot of caution. Making a full backup is an essential first step.

Scan Media Library for Unused Media Assets. The first is to scan your Media Library for images that aren’t actually used in posts on your site. This function is available in the free version of the plugin.

Scan Your Uploads Folder for Files Not in the Media Library. The second is to scan your uploads folder on the filesystem for images that don’t appear in your Media Library. To access this function you need to buy a license for the Pro version. Pricing is based on the number of websites, and you can make a once-off payment or subscribe annually.

It’s straightforward to use once you’ve installed and activated it just like any other plugin. Firstly, you set the options you want by going to Settings > Media Cleaner.

Media Cleaner for Wordpress options panel
The options panel.

You actually run the scan and do all of the deleting, etc, by going to Media > Cleaner.

Once you get the results, which come out like the screenshot at the top of this page, you can select what to do on a file-by-file basis or globally. Any files you delete go into the Trash as a safety precaution. You can then empty the trash if you want to delete them permanently.

And it’s worth including the developer’s in-depth warning panel here to emphasize the point that it should be used with caution.

Media Cleaner for Wordpress warning panel

Does it Work with Multisite?

The developer hasn’t fully tested it with multisite, but I’ve been using it without issues on my multisite install. Your mileage might vary—again, use with caution.

Wishlist

Media Cleaner is quite new and there’s plenty of room for it to grow. One issue that I’ve run into is that webp versions are showing up as not in the Media Library, including the webp version of every thumbnail size. So I’m getting pages and pages of webp versions in the results. I’d love to be able to filter out webp versions from the results and, beyond that, be able to filter by filetype or filename string. I’d also like to be able to select particular folders within the uploads directory rather than scanning the whole thing.

Registering Uploaded Images in Your Media Library

What if you want to do the reverse? That is, what if there are in images in your uploads folder that aren’t showing up in Wordpress’s Media Library but you want them to? A common reason this comes up is if you’ve uploaded files via FTP, perhaps when moving a site between hosts. Sometimes the images can become unregistered from the Media Library.

There’s a separate plugin that can handle this: Media from FTP.

Basically, it scans your uploads folder, finds files that aren’t registered in the Media Library, and asks if you want to add them. There are various options for filtering and even modifying things like the file’s date and time.

I’ve had mixed success with it, which isn’t the fault of the plugin but because there are several different ways things can become messed up in the first place, and there’s only so much a plugin can do to fix every possible cause. But when it works, it’s saved me an enormous amount of time and effort, so it’s definitely worth taking a look at.

Profile photo of David Coleman | Have Camera Will Travel | Washington DC-based Professional Photographer

David Coleman

I'm a professional photographer based in Washington, DC. Seven continents, up mountains, underwater, and many places in between. I've been shooting for 30+ years, and my photos and time-lapse videos have appeared in a bunch of different publications, from major newspapers to magazines and books, billboards, TV shows, professional sports stadiums, museums, and even massive architectural scrims covering world-famous buildings while they're being renovated. You can see some of my travel photography here and here.