Announcement

MORE THEMES - The next new theme is being developed.

How to remove unused images in your WordPress website

Have you ever looked inside your media library or better yet, the uploads folder in your site files? If your WordPress, plugin, and theme generates custom thumbnail sizes, you just might pass out from a very bad problem that exists in the world of WordPress. Even I was surprised when I looked, but let’s take a moment to go through the what’s, why’s, and how’s of keeping your WordPress image media library under control.

You may want to read my other article about WordPress Post Thumbnails and How they Affect your Website.

How are Thumbnails Created?

There are three ways thumbnails are generated in your WordPress website:

  1. WordPress Media Settings – Image sizes are set, and each one will generate a thumbnail + the original photo
  2. Themes – Themes will have added thumbnail support with many also adding additional thumbnail sizes
  3. Plugins – Plugins that support some form of image upload such as sliders will add to your thumbnail growth

The problem is that without managing what thumbnail images created and by what, we will find ourselves with a massive clean-up to perform. Or worse, create a problem that many are not aware of.

Luckily, with our WordPress themes, we give you the option in the Customizer to enable thumbnail creation if you choose to. Unfortunately a lot of themes don’t give you that option; they simply have this function enabled based on the theme you are using.

Thumbnails from Hell

To give you an idea of what kind of mess you could encounter, I will show you with some screen shots, the first shows uploading 16 pictures but having several different thumbnail size settings. With all the other images, my uploads folder had over 57 MB of thumbnails.

thumbnails overload

Perhaps a bit exaggerated, but here is another one from testing my free WordPress theme called JustBlog and uploading a featured image for the blog. However, to show what can happen with just one picture, I enabled the thumbnail creation for the other blog styles too:

thumbnails overload 2

Granted, you don’t need to turn on all the blog styles because you can only use one at a time, but aside from the original, the picture became 12 thumbnails. Basically what I needed for the website are:

  • the original at 960×720
  • a related post thumbnail for 210×150
  • recent posts thumbnail for 340×75
  • and the default blog style at 740×400

….the rest are not needed, but it can show how easily it can become a major problem with uploading just 1 picture. Imagine uploading pictures for a month, or even a year!

The Problems this can Cause

Getting buried under an avalanche of thumbnails can cause a lot of problems for you and your website. Let’s begin with your web host account…

When you sign up for hosting, you get a certain amount of disk space to store your website files and anything you add to your website like images, files, and other types of media. In most cases, web host providers give you a lot of space, but don’t take this for granted because if you upload a lot of images, your space could soon run out. Your web host will either bill you for the additional space requirements, or they could demand you upgrade to a bigger package. Either way, you are paying more money.

Another problem is the size of website backups. If you backup your website (and you seriously should be doing this), your website will take longer to backup and your backup files (archives) will continue to get larger.

How to Fix the Image Thumbnail Problem

Now that you know how thumbnails can be generated and the problems unmanaged media can cause, it’s time to turn out focus on fixing the problem.

WordPress Media Settings

When you first install WordPress, one of the very first things you should do is go to the settings for “Image Sizes” and change them:

wp media sizes

By default, the values you see in the above screenshot are predefined in WordPress when you have a new installation. In a nutshell, every photo you upload will get a custom thumbnail generated to each size you see. In a nutshell, 1 photo becomes 4. I’m sure you are now thinking, wait, there’s only 3 settings, where is the fourth?

The fourth thumbnail is actually the original photo you uploaded. If you upload a photo that is 1200×1200, you will get the following sizes:

  • 150×150 pixels
  • 300×300 pixels
  • 1024×1024 pixels
  • and then the original 1200×1200 pixels.

The generated thumbnails is supposed to give you the option to insert photos into your page or post and choose the size of thumbnail you want.

What you will want to do is change each setting to a zero ( 0 ) which tells WordPress not to make a thumbnail for each size. If you think you might be creating galleries using the WordPress gallery shortcode, you can set the “thumbnail size” option to something of preference and make sure you check the box “Crop thumbnail to exact dimensions”.

I usually make the thumbnails much larger than the 150×150 because if you plan to have captions, 150px is too small—opt in for something a bit larger.

Disable Theme Thumbnail Creation

I cannot vouch for other theme sites and authors, but here at Blogging Theme Styles, the option to enable/disable thumbnail creation is turned off by default. You will find these settings in the theme Customizer, so they are easily accessible. If you are lucky to be using one of our themes, make sure you turn on the settings only for the thumbnails you want generated for your website and leave the others off.

Plugins that Create Images

If you are using a slider, for example, they will usually generate slides from the photos you upload. There a ton of slider plugins, so check yours and see if there is a method to disable any unnecessary thumbnails, but also check that they do not create slide thumbnails for images that are not related to the slider.

Upload Your Own Cropped Images

If you have the opportunity to create your own cropped and sized image; I would recommend you do this instead of using WordPress, themes, or plugins. This gives you more control over how images are cropped, sized, but also gives you the means of optimizing your photos as well. The other advantage is that you only upload what you need, nothing more.

How to Delete Unused Thumbnails

This is probably one thing that you MUST BE CAREFUL with so that you don’t accidentally delete images that are being used. I know some people will say just go in and start deleting, but that is dangerous advice.

The best way to clean house is to use a plugin that deletes, removes, or cleans up unused thumbnails, files, and other elements that are not being used or connected to anything that needs them. I recommend checking out the WordPress.org website for plugins that can do just this, but make sure the plugin is up-to-date, their support is active, and read reviews.

In Summary

The best way to manage thumbnail saturation is to be proactive right from the start. Be aware of what is generating thumbnails in your site because over a span of a year, you could end up with an overwhelming archive of images. Having thumbnails created for you is not a bad thing, it’s just that you have to be aware of them.

Now, before you do anything, I say this to people…

BEFORE DOING ANYTHING, ALWAYS MAKE FULL REGULAR BACKUPS OF YOUR WEBSITE!

Always best to play it safe and to expect the unexpected.