How to clean the WordPress Media Library
The Media Library is where WordPress stores all the images and other files — PDFs, Word docs, etc. — you insert into pages and posts. Over time, the Media Library can become cluttered with duplicates and files that are no longer used on the site. Let’s see why this is a problem, and learn how to clean the WordPress Media Library.
Why you should clean the WordPress Media Library
A cluttered Media Library makes it harder to find files when you need them. Cleaning the Library makes it easier to find your files.
The unnecessary files take up space on your web server. Some hosts limit the amount of storage included in your plan and might require you to upgrade to a more expensive plan if you exceed that amount.
Cleaning the Library reclaims space on your web server, potentially saving you money.
The unnecessary files take up space in your backups. Some backup destinations limit the amount of storage included in your plan and might require you to upgrade to a more expensive plan if you exceed that amount. Other backup destinations, such as Amazon S3, charge you for the amount of storage you use. Learning how to clean the WordPress Media Library reclaims space on in your backup destination, potentially saving you money.
One way to decrease clutter in the first place is to avoid duplicating files in WordPress. Before inserting a file into a page or post, see if it’s in the Media Library. If it is, insert it from there, rather than uploading it from your computer again. I’ve seen many sites with a couple to a dozen copies of the same image because someone didn’t know they could reuse images from the Media Library!
Options for cleaning the Media Library
As with most things in WordPress, technology and life, there’s an easy way and a hard way. As is usually the case, the easy way involves tools and automation, while the manual way involves more human effort.
Whether you use tools or do it manually, make a full backup first! When you trash a page or post, it moves into the Trash, where you can easily restore. It works the same way as the Recycle Bin in Windows or the Trash in MacOS.
However, files in the Media Library don’t go to the Trash — they’re permanently deleted. If you accidentally delete something you need, you’ll need to get it back from your backup or upload it again from your computer.
When I say take a full backup, I mean one that includes all the files of your site, including the Uploads folder (/wp-content/uploads/). Check the settings of your backup plugin or system to be sure it includes that folder. Even better, check your backup and confirm that it contains the files of your Media Library.
The easy way: Media Cleaner plugin
When you’re looking for the easiest way how to clean the WordPress Media Library, use the Media Cleaner plugin from Jordy Meow, a reputable WordPress plugin developer. This plugin scans your Media Library to determine if any files are not used in any of your posts, pages, etc.
When you delete files, it moves them into a temporary trash (as long as your site allows that; the plugin will tell how you to enable it if necessary). Once you confirm that your site truly doesn’t need the items, you can permanently delete them.
You can find instructions on using Media Cleaner on the plugin’s page in the WordPress Plugin Directory, as well as on the plugin author’s site. After you install and activate the plugin, review the settings (Meow Apps > Media Cleaner). I recommend checking the boxes to analyze Posts, Post Meta, Galleries, and Widgets. To run a scan, go to Media > Cleaner.
The plugin isn’t perfect — it sometimes says files aren’t in use when they actually are. This usually happens when the file is unattached from content where it’s included. For that reason, it’s a good idea to confirm that files are really unused, which you can do by following the steps below.
The hard way: manually
Some people don’t trust automation. Others see themselves as craftsmen and prefer to work by hand. These attitudes carry over into how people decide how to clean the WordPress Media Library.
If you prefer to roll up your sleeves and get under the WordPress hood, you can manually clean the Media Library. Switch your Media Library to List View (use the icon at the top left of the page) and look at the Uploaded To column. That tells which page or post the file was uploaded to.
Now, this doesn’t mean that the file is still used on that page or post, or that it’s not also used in other places (pages, posts, widgets, theme, etc.). So, you need to do some deeper digging.
When you’re looking at your Media Library in List View, look at the File column. You’ll see the file name of each file, for example, Nerd-Balloon.jpg. Now, you want to see where that file name appears within your website.
When you upload an image to WordPress, it automatically creates several copies of the image at different sizes. For example, if you insert Nerd-Balloon.jpg at the Large size, the URL WordPress will insert will end with Nerd-Balloon-1024×752.jpg.
So, you can’t search for Nerd-Balloon.jpg, because that won’t match. Instead, you need to search for Nerd-Balloon, the part before the size and file extension.
Now, click on each section of your site (Posts, Pages, Products, etc.) and use the search box in the top right. In our example, you’d paste Nerd-Balloon and hit Enter. That will show the places that the file is used. If there are no results, then you have no content of that type using the image.
In our example, let’s say you searched within Posts and found no results. Then you can search in Pages next, and so on, checking the types of content where you think the file might be in use.
As you learn how to clean the WordPress Media Library, pay attention to whether the content is published on your site. You might find the file used on drafts or trashed content. In that case, decide whether you’ll ever publish that content. If not, you can safely delete the file from the Media Library.
If you don’t find the file anywhere on your site, then it should be safe to delete the file from the Media Library. If in doubt, leave the file in the Media Library rather than risk removing something you need!
Video walkthrough: cleaning the WordPress Media Library
Grab your mop, er, mouse, and start cleaning!
Now that you’ve learned how to clean the WordPress Media Library, follow the steps above to back up your site and declutter your Media Library. When you finish, take a small break to celebrate.
Then, continue your cleaning spree by decluttering the rest of your WordPress site. It won’t be the most fun thing you do this week (I hope!), but you’ll smile as you observe your sparkling clean WordPress site, and your site will run more smoothly, too!
The GoDaddy product information in this article is outdated and currently under review for accuracy. For the latest up-to-date product information please visit godaddy.com