Media Cleaner

Delete unused files from WordPress

Do you run a popular website about WordPress, photography, or do you have another way to talk about my plugin? I can share a free license against some promotion of my plugins. As you might know, I don’t do any marketing, I prefer to focus on quality and support πŸ™‚ If you are interested, contact me

Media Cleaner is a tool that detect unused and useless files from your WordPress. It cleans clean your Media Library and your Uploads Directory.

Media Cleaner for WordPress

 

You can choose to check your Media Library or your Uploads Directory. Then the plugin will check if the file (or files, in the case of a media) is used anywhere in your WordPress install depending on the options you have chosen. Here are a few examples of what can be checked:

  • physical file not linked to a media and/or to anything else
  • the media not used in any posts and/or anything else
  • the media is not used in any gallery, postmeta
  • the Retina image is an orphan, the normal file is gone
  • etc…

Basically, by playing with the options, you can discover a lot about how your system is used and how much (in term of weight) of images became useless.

Media Cleaner Settings

The files (or media) is then added to the Media Cleaner Dashboard. From there, you can choose to move then in the trash. The next step is to test your website, maybe for a few days or more; if nothing is missing, if all is working well, it means none of those images were actually in use. Then you can decide to trash them completely.

Even if the plugin is on the safe side and has this trash system included, make a proper backup before using it. If you don’t really know what you are doing, simply do not do it.

Examples

Personally, I have one website on which I use my images in posts only (http://jordymeow.com). I set the Method on Media Library and the only options I check is “Posts”. I usually get very interesting results of Media I actually don’t use or stop using.

I have another website which is all made with galleries (WP Gallery). Again, I use the Media Library method but this time I only check “Galleries”. I realized this way that there are images I forgot to include in my galleries.

The way I love to use this plugin is every time I switch theme. When I do so, I need to regenerate my thumbnails and my alternative images (with a plugin such as Regenerate Thumbnails) and by doing this you end up with a lot of new images being created; however, the old ones are still here! They aren’t registered in your Media Library (the Media exists, but the alternative size is not part of the metadata), it’s actually a mess. Media Cleaner is safe and will mark them as being used if you scan with “Posts”. However, there is a way to find those files which are actually disconnected from your WordPress. Method “Filesystem”, and check only “Media Library”. You will probably discover a huge amount of files which are completely garbage, but be careful, they might still be used in the “Posts”. You need to update your articles (that can do it by editing your posts, clicking on those images and edit, and Update; the HTML will be updated by WordPress with the proper alternative image).

Let me know how you use it, it’s always good to know πŸ™‚ Enjoy the plugin!

 

  • Pingback: WordPress Plugins A-Z #255 Media Library, Stopping Bots()

  • Flexicodes

    Question about your Media Cleaner plugin: Do you know if it works with the ACF plugin? Can it tell if the image is used within ACF fields in the WordPress installation? Thanks!

    • Good question! I am not using ACF myself but if this plugin is using post_metadata, which I guess it might be using, then it would work. But it’s better to make a test beforehand, just to make sure πŸ™‚ If you do, please come back here and tell us if it works. I will try someday as well.

      • Flexicodes

        Thanks, I’m a firm believer of the test, test and retest thought process so I will definitely be doing that for the client. I will check it out and let you know. It just seems that some of the WordPress generated Thumbnails started showing up in the clients Media Library which they don’t like because all of a sudden they are like 12 “extra/duplicates” of the same images showing up. I want to try to remove the thumbnails from the library and then regenerate them and hope that they stay in the background like normal. Hopefully your tool helps otherwise it might have to be a manual approach.

        • In that case, I recommend you to pick only the image sizes you need (maybe disable the ones you don’t need), regenerate the thumbnails (any of those plugins will not remove the old ones unfortunately) so that the metadata is clean, then run the Media Cleaner with the Filesystem mode, only with Media Library checked πŸ™‚ That way you will detect all the useless sizes image files. Let me know how it goes πŸ™‚

  • Awesome plugins you make! I have just purchased both Renamer, Retina and now Cleaner.

    But I have a little issue I can’t figure, so I hope you can help. I made a bulk generate in retina with all my images. It went perfect, but some days later I regenerated all images (with the Regenerate Thumbnails plugin), because I have changed the dimensions for large thumbnails from 1024px to 625px.

    Then I made a scan in Cleaner with the Filesystem method and the Media Library checked. It found a lot of images but not the 1024×512.jpg 1024×512@2x.jpg images!

    How do I delete all old images sizes?

    Is it better to use the other plugin Force Regenerate Thumbnails (https://wordpress.org/plugins/force-regenerate-thumbnails/)?

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