Meow Apps

Media Cleaner: Tutorial

Media Cleaner is a very advanced tool and should be used by someone who understands the mechanics of WordPress very well. This is not a one-click cleanup kind of tool, and cannot be. Also, cleaning the database of temporary entries or old drafts is easy, but files always are potentially in use. Media Cleaner is a tool in your hand. Make sure you are in control of it.

Remember to backup your install (the database and the /uploads directory) before using this plugin. I recommend you to use your hosting service backup system if they have any, a staging website if you use WPEngine,or the very well-made BlogVault service.

The Dashboard

The Media Cleaner’s Dashboard is found under Media > Cleaner. Before doing anything here, you will need to decide your settings. However, it’s better to understand how the plugin works, and this dashboard is where the magic happens.

Media Cleaner for WordPress

Here is how you should use the plugin, without going into the details of what the scan is really doing and how. Again, remember that you must prepare a backup before doing all this.

  1. Scan. You can click Start Scan , and then enjoy a coffee. The plugin will analyze your WordPress. Once it’s done, the results will be displayed. 
  2. Verify. There might be false-positive in those results, particularly images used by the theme directly, such as the logos, headers, etc. Look for them, and if they are part of those results, select them and click Ignore. They will never be deleted by the plugin.
  3. Delete or Ignore. You can search (= filter) through them. If you click Delete all after a search, only the results of this search will be deleted. You can also delete the entries one by one or by selecting a few of them. If there aren’t enough entries listed on each page for you, you can set this up differently in the settings. Remember that the files are being moved to the internal trash of the plugin, so they are still taking space in your install.
  4. Test and Repair (if needed). Browse your website thoroughly. If possible, let it be for a while, without adding new content. Is a file missing? Go back to the dashboard, click on Trash, find the entries, select them, and click Restore
  5. Free space. Has everything been fine for a little while? Click on Empty trash. The entries will be permanently deleted. Good job!

Now that you know the process of Media Cleaner, let’s have a look at the settings.

The Settings

The settings are found under Meow Apps > Cleaner

Method

This is the most important setting. In the Free version, only the Media Library method is available. This will go through all the registered media and it will check if they are in use. The Filesystem method will go through all the files under your /uploads directory, and will check if they are registered as a media and/or use somewhere else (check the Scanning settings to know more about this).

Scanning

Filters

Filters are only useful with the Filesystem method. 

Directories Filter and Files Filter can restrict the scanning to specific folders and/or files depending on a regular expression (expressed between two slashes). If you don’t know how to write a regular expression, it might be interesting for you to learn. There are many tutorials online, and then you can test them on websites such as Regex101. Here are a few examples:

Thumbnails Only will only scan your thumbnails and avoid the original (full-size) images. This could also have been done with a regular expression but is to make life easier for most users. Have a look in the Recommended Procedures for the usual usage of this option.

Before the filters are applied, the scan will need to go through all the directories and files first, so not be surprised if you see the plugin analyzing a directory which logically should be skipped (a directory that matches the filters might actually be under it, this is why).

Recommended Procedures

Do you have a headache already? Simply discover the different kinds of checks and actions you can perform. They represent the typical usage of Media Cleaner.

Standard Check (Media Library Method)

The basic settings for a first scan are those. I recommend you to consider Posts, Post Meta, and Widgets as a set. All of them together represents the content of your website.

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.

Meticulous Check (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 🙂

Broken Media Check

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.

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 🙂

Pick Filesystem as the method, then check Thumbnails Only.

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. You probably want to regenerate the fresh thumbnails that you need with another plugin after that. Remember that if you don’t need all those image sizes, you can use the remove_image_size function of WordPress or plugin such as Stop Generating Image Sizes.