Unused Images

How it works

WordPress stores images in two parts:

  • The image files are stored on the server, typically in the ‘wp-content/uploads’ directory of the site.
  • A record of the image is then stored in the database, in the Media Library. This record also includes other data related to the image, such as the image tile, description or alt-text.

Images in the Media Library are also stored in different sizes, with a separate image file on the server for each size (typically thumbnail/small/medium/large). This can cause the uploads folder to become bloated with unused image files.

When populating the list of unused images, you can use WP-Optimize Premium to check both these locations for images

WP-Optimize will then scan the database for each of the detected images. This includes checking any posts, pages and custom post types (such as FAQs or eCommerce products) for featured or embedded images. Any image that can’t be matched to a record in the database will then be added to the list of unused images.

Please note that certain themes or page-builders may access images in a non-standard manner, in which case the images may be flagged as unused incorrectly. We recommend double checking before deletion if you are unsure, and keep an up-to-date backup of the site.

When removing an image, both the image files and Media Library record will be deleted.

Removing Unused Images

Open the ‘Images’ tab in the WP-Optimize admin page and press the “Unused images and sizes” tab.

To scan your website for unused images, press the “Scan website for unused images” button. WP-Optimize will now scan for unused image files, found both in the Media Library and the ‘wp-content/uploads’ directory, that are not attached or embedded in any posts or pages.

You will now be presented with all the unused images that are on your site. To delete these images, either individually select the images by clicking on the images to highlight them, or press the “Select all” button to delete all unused images.

Once you have selected all the unused images you want to delete from your site, scroll down and either choose “Move selected images to trash” or “Delete the selection permanently”. WP-Optimise will then delete all copies of the selected image file plus any record in the Media Library.

You will receive a notification that your images have now been deleted.

Removing Images by size

By default, WordPress creates 3 sizes for every uploaded image. Not all image sizes are used. And so this Premium feature allows you to see a list of all registered image sizes, as well as registered image sizes not in use, which can then be removed. Just press ‘Scan website for unused image sizes’ to see a list of results.

Restoring images that were moved to trash

If you are not sure if you might still need the image, you can send it to trash, instead of deleting it permanently. You can view and restore these images by pressing the “view trash” button. 

Here you can restore any trashed images you want to keep by highlighting them and pressing the “Restore the selection” button. These images will now be sent back to your image library. 

We recommend taking a backup of the site before performing any optimisation with WP-Optimize. WP-Optimize integrates with our backup plugin, UpdraftPlus. If UpdraftPlus is active on the site, the option to take an automatic backup before images are removed will be displayed in the tab.

How do I use WP-Optimize image optimization?

For a detailed walk-through on how to use the WP-Optimize image optimization feature, we put together a video that takes you through all the necessary steps:

Full written instructions on how to best compress and optimize your images can also be found here.

What is Optimization Preview

Optimization Preview gives WP-Optimize Premium users the ability to preview, select and remove data and records available for optimization from the database. This preview process lets the user check the relevant data before running the optimization, which helps avoid mistakes such as removing potentially useful information.

To View:

  • Open the WP-Optimize tab
  • View the preview information (see arrow below) on what files are available to be optimized or deleted

 

Why is the gain from compression so low for some images?

Since WP-O only employs lossless image optimization by default, the optimization value depends on the amount of (unnecessary) metadata saved in the image and the composition of the image itself. The more metadata can be removed from an image, the higher the reduction that can be achieved through optimization.

Will the quality of the image suffer?

There may be a slight loss of image quality, but in most cases the quality loss is so tiny, it can’t even be noticed. Once your images are converted to a smaller file size, you will of course lose some of the data from the original file and the more you compress it, the more degradation occurs. One of the biggest reasons why we use lossy compression is that it maintains better image quality compared to lossless compression, while still giving a significantly reduced file size.