Tutorial: Cleaning WordPress with Media Cleaner

Media Cleaner is a very advanced tool and should be used by someone who understands WordPress well. Then it will deliver amazing results. First, remember to backup your install (database and /uploads directory) before using this plugin. If you don’t know how to, I recommend you the UpdraftPlus plugin. You can also do this on your staging website if you use WPEngine for example.

1. Introduction & Media Library Method

The basic/recommend options for a first scan are those. I recommend you to consider Posts, Post Meta, and Widgets as a set. There could have been only one checkbox called Content instead of those three.

Media Cleaner

Start the scan, then wait. It takes time depending on your install. If it stops suddenly, please check how to debug Media Cleaner. When it is finished, have a look at the results and firstly, search for the images used by your theme directly (usually, the header, the hero, the logo). Those might have been detected by the plugin but it is not certain, as it is often used silently by your theme. Mark them as ignored if they are part of the results.

Check the files which were detected as not in use. Are they really not in use? Check a few of them randomly, at least. Then delete them with the plugin. They will be moved to the plugin’s trash and the database entry for the media will be also kept.

Use your website for a while. Everything works? Empty the trash. Many broken files? Restore them using the Media Cleaner dashboard, or your backup.

2. Meticulous check with the Filesystem Method

I recommend doing this after having checked your Media Library first. Now that your Media Library is clean, we would like to know which files in your /uploads directory are actually not registered as part of a media. I would preferably use the following settings.

Media Cleaner Settings

All the files which are not part of a media will be detected. This makes sure that everything in your files is actually properly registered in your Media Library.

The combination of those two checks will make your install very optimized, sparkling. Everything is used and properly registered. Of course, this is ideal 🙂

3. Alternative: Check for Broken Media

Maybe you don’t really want, need or can perform a meticulous check of your install, and what you need is simply to detect the broken medias (which doesn’t have any files behind them). This scan will exactly require those settings.

Media Cleaner Settings

Logically, doing this would actually detect all your media as not used by your system, since they are not checked against anything. But the Media Cleaner will recognize those settings and will display a message in your dashboard to let you know that it will only scan for broken media.

4. Alternative: Delete all thumbnails

There are plugins which are supposed to delete the thumbnails, but they actually only delete the thumbnails which are registered, and don’t see the previously created ones. Only Media Cleaner can do that, so please take advantage of it to clean your install easily 🙂 In that case, it doesn’t make much sense to analyze your install for references, you will just want to get the list, then delete them (and you probably want to regenerate the fresh thumbnails that you need with another plugin).  Pick Filesystem as the method, then check Thumbnails Only.

The Settings

  • Media. Only for the Filesystem method. This will check if the files are registered in a media, including all the sizes.
  • Posts. This is important as it checks the content of your posts. The URLs, the CSS classes using the IDs of the media, the background images, the src-set even, and more. I have one website on which I use my images in posts only (this one: Offbeat Japan). I set the Method on Media Library and the only option I check is Posts. I use my Featured Image in my posts directly as well, but if I was not using it, I would also need to check Post Meta, as the Featured Image is stored in it.
  • Post Meta. This is where the Featured Image is stored, but not only! Many Page Builders are also keeping their data there, sometimes galleries, and so on.
  • Widgets. This is simply the widgets you have added. They sometimes contain images or even galleries.
  • Logs. This will create a file (reset for every scan) containing all the files detected in your install in a first section, then the result of the scan for every media/file in a second section. Very useful to debug the plugin.

I recommend you to use WPEngine or SiteGround. They are both excellent hosting services and work perfectly with all my plugins.