Wordpress - How To Delete Desired Image Sizes From wp-content/uploads?

A quick and easy fix for this is to make use of a plugin called Force Regenerate Thumbnails (to which I don't have any affiliation to)

Unlike a plugin like Regenerating Thumbnails, Force Regenerate Thumbnails creates all your new custom sizes and delete all redundant/orphaned sizes.

Force Regenerate Thumbnails allows you to delete all old images size and REALLY regenerate the thumbnails for your image attachments.


That's easy! If you have SSH access, log in and do the following for each size. I am just showing 150x150 size only.

Go to the desired uploads folder via command line.

cd /your-site.com/wp-content/uploads

Let's find if that size is available.

find ./uploads/*  -iname '*-150x150.*' -ls

If you see some images as the output then delete 'em with

find ./uploads/*  -iname '*-150x150.*' -exec rm {} \;

Do make sure you back up everything before running such a command.

Or you can search for all the resized images with this command

find . -regextype posix-extended -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -type f

If there are any. Then you can delete them all with the following command

find . -regextype posix-extended -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -type f -exec rm {}  \;

Again, make sure you back up everything before running such a command.

After all that, instead of generating all sizes again, you can use OTF Regenerate Thumbnails.

This plugin behaves similarly to Regenerate Thumbnails except that images are resized automatically / on the fly, when they are used. Once created, they won't be processed again.

Cheers!