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.
  • 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 πŸ™‚

      • I am using ACF and I did a scan and its showing files that we are using, which are part of ACF related files field.

  • 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/)?

  • Mohamed M. Roushdy

    i am trying to use the Media Cleaner, but when I press scan, nothing happens. is this because “The trash for the Media Library is disabled. ” or this has nothing to do with it, and there is something else i am missing!

    • Mohamed M. Roushdy

      I am using WordPress 4.7.2 and a theme called Flatsome 3.2.5 and its Child Theme.

  • Inertia Interactive Media

    Where the heck is the field to add a serial number?

  • Eduardo

    Works with woocommerce images?

    • Normally yes, but WooCommerce has a lot of different features so it’s hard to say. It’s better to try and come back to me if there is an issue.

  • Hi – I just bought the Pro version of Media Cleaner – currently test driving… first impression is plugin is well engineered πŸ™‚ I have a possible suggestion for next-gen: an option to delete and redirect? BECAUSE if the image was ever in the wild and indexed by Google it will become a 404 in your Search Console. And / or maybe mark as 410 gone? Integration w Yoast / All-in-One? Love to hear thoughts of SEO mavens. Thx

    • Hi! Thank you for liking it, yes, a lot of thinking was put into it since it’s a hard plugin to make. So don’t hesitate to give me a little push with a good review on WordPress, that will balance the bad ones πŸ™‚

      Redirection is a very tricky subject as well, there are big plugins doing that, it’s not a tiny feature, so I can do that in the plugin itself. Of course, I could “communicate” with another installed plugin to take care of this. But to be honest, if a photo is not in use then Google should get a 404 on it, it shouldn’t be referenced anymore, otherwise it should be redirected to… what? πŸ™‚

      • Good point – in the case of a duplicate file (i have lots of those from changing thumb sizes) redirect – if the file is gone then rightfully it should probably be marked 410 I would think – but if the file is gone *what* exactly do you mark 410? This stuff gives me brain freeze πŸ˜‰

  • Thanks for making such a great plugin. I can’t install it though, it says that it doesn’t have a valid header. Using latest wordpress.

  • Jason

    Hi, where do you put the code to activate the PRO version? I find it is not very obvious.

    • Hello! In the Meow Apps menu in WordPress, then Media Cleaner πŸ™‚

      • Jason

        Ya it’s weird it’s not there and I downloaded the most recent ver.

        • From the WordPress Repo? Because that’s the Free version πŸ™‚ For the Pro version you need to use the link you got in your welcome email after buying the plugin.

  • I can’t get the plugin to scan for any files. This is driving me crazy. I just bought the PRO version…

  • Christian Fischereder

    Hi Jordy,
    you write “Visual Composer is not supported as for now…”
    Will the MediaCleaner be extended to detect also files used with Visual Composer?

    Many thanks in advance!
    BR, Christian

    • Hello! I would need to work for a few days on the plugin so it’s a bit difficult to do right now unfortunately πŸ™

      • Christian Fischereder

        Hi Jordy, Just for the info, it would be quite possible for me to pay a working day officially. And it does not have to be immediate … BR, Christian

  • David Jeffries

    Hi Jordy,
    I have added the line define( ‘MEDIA_TRASH’, true ); to my wp-config but still it saying to add it? should it disappear once I have added this line to the config file?

    https://uploads.disquscdn.com/images/c1d4ffcdbf24c31b3eff9f08d4f1e885d660f0b48aae039feb5c2f2e8eb0dbfb.jpg

    • Hello! Yes, it should go away. Are you sure you put it in the right file? Or maybe your install is totally ignoring this for some reason, but I don’t see how that would be possible :/

      • David Jeffries

        I moved the line further up the config file and it accepted it, adding it to the end of the config file it doesnt work… Thanks Now to run it…

    • David Jeffries

      Ok, that response isnt very helpful… I’ve paid for the pro version, whyu isnt it working? its found 166 unused images ((apparently) a good thing with 2000 images on the site, however I cant safely delete them as there is no trash option, help?

      • Sorry, it’s hard to tell you why the trash function is not getting enabled, it’s actually not part of my plugin, it’s part of WordPress. My plugin simply tells you that it is not enabled. It’s not safe to delete them, but of course you could check if they are indeed not in used yet; I can also try to access your install and see why if this is really not enabled, but if you update your wp-config.php accordingly (by adding this line at the end) it should really really work. I really want to help but the best I can do is to have a look at your install. Contact me directly if you wish me to have a look.

  • Hello!

    How do I get the plugin to search and analyze images in the background using CORN?

    • Hi, you mean with CRON? πŸ™‚ It’s not possible currently. To be honest, it’s usually not good to do things through CRON in WordPress as it’s not really a real CRON and there are many cases where it will not work nicely. The cleaner is a process better watched closely, in a tab.

  • Jodi Solbrig

    I’m trying this plugin out, but I get “Preparing medias (0 media)….

    Everything else, seems to check out fine. Any ideas for me?

    No errors in apache2 logs.

    Checked server processes, doesn’t seem to be doing any work.

    have let it sit for 15 minutes with no changes. We do have a very large inventory of media.

    ideas?

    Would be happy to purchase if it works and does the job!

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