WordPress

How to clean up your WordPress media library

Written by Kevin Kyburz

Updated on

Clean up WordPress media library cover image

If you have been using WordPress for your blog or company website for some time, you have probably uploaded quite a few files to the media library. When you upload a file, WordPress creates several copies of it (e.g., different sizes for preview images). If a post or page is deleted, the images remain on the server and slowly fill up the hard drive and database. We believe that you should give your WordPress site a spring clean once a year to free up space and keep your backup nice and slim.

We'll show you step by step how easy it is to automatically clean up your media library.

Please note: In the following instructions, we use two WordPress plugins that help you permanently delete images from your server. Use these tools carefully and consider creating a backup beforehand.

Media Cleaner – Deletes images that are not used

A really great plugin is Media Cleaner by Jordy Meow, who also developed the popular WP Retina 2x. Media Cleaner is free, but is also sold asa pro version, which gives users more features.

After you have installed and activated the plugin, you will find a new submenu called "Cleaner" in the "Media" menu item. When you first open the page, the plugin may ask you to reset it. This simply involves creating a new database table in which the WordPress pluginstores its information.

By clicking on "Start scan," the plugin will now search the media library and check which images are used in a post and which are not. Such a scan is usually very quick, but takes longer the more images have been uploaded. Once the scan is complete, unused images will be displayed.

Media Cleaner WordPress Plugin

Now you have the option to delete these images. Either individually or with the "Delete all" button. The great thing about the plugin is that the images are first moved to the recycle bin during the first deletion run. This gives you the option to restore the content in case of an error. However, this option should not be considered a backup!

It is important to note that the free version of the Media Cleaner plugin does not scan images that are used in the following plugins or theme builders, for example: 

  • ACF (+ ACF Widgets)
  • Divi Builder
  • Fusion Builder (Avada)
  • WPBakery Page Builder
  • Visual Composer
  • Elementor
  • Beaver Builder
  • Brizy Builder
  • Oxygen Builder
  • Slider Revolution
  • Avia Framework

With Theme Builder in particular, this can result in the pages no longer having any images at the end.

Media Deduper – Finds duplicates and removes them

Our second WordPress plugin, which is very popular and does a great job of cleaning up your media library, is the "Media Deduper" plugin. Unlike "Media Cleaner," this plugin searches for duplicates, i.e., duplicate images. These are found and removed based on the file, not the name.

Even though this plugin is free, there is also apro version available, which we highly recommend. With the paid version, your images in a WordPress gallery, Yoast SEO, and WooCommerce will not be deleted.

Once you haveinstalled and activated the WordPress plugin, you will find a submenu called "Manage Duplicates" in the media library menu. Click on "Index"to scan your media library for duplicate images

Here, too, you should create a backup of your WordPress site beforehand.

Media Deduper WordPress Plugin

Once the scan is complete, you will see a list of duplicate images. Delete these using Smart Delete, as this feature ensures that images used on your WordPress site are not deleted. Duplicate images are also merged so that you can reuse these media files without having to upload the same file again.

Conclusion

The ease with which images can be uploaded to a WordPress site often leads to a rapid accumulation of unnecessary images and clutter on the hard drive. Although we believe in installing as few plugins as possible, in this case it does no harm to use one of the two to clean up the media library.

It is important to create a backup beforehand so that permanently deleted files are not lost forever.

Kevin Kyburz

Kevin Kyburz

Founder and CEO

From my very first steps on the internet, I was overwhelmed by the unlimited possibilities. Twenty years have passed since then, and my interest has not waned in the slightest. Today, I combine my passion for SEO, marketing, and WordPress within this:matters.