Remove all resized WordPress media images

by Michael Cannon in Featured, Server, WordPress · 2 comments

Abandoned resized media images

When shifting through WordPress themes utilizing a variety image sizes, your wp-content/uploads or wp-content/blog.dir directories can get full of abandoned images. An easy way to get rid of those abandoned images is to delete them and then regenerate those that you actually need.

SHOW all resized images

cd /home/example/public_html/wp-content/uploads
find . -regextype posix-extended -regex ".*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)" -type f
cd /home/example/public_html/wp-content/blogs.dir
find . -regextype posix-extended -regex ".*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)" -type f

DELETE all resized images

cd /home/example/public_html/wp-content/uploads
find . -regextype posix-extended -regex ".*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)" -type f -exec rm {}  ;
cd /home/example/public_html/wp-content/blogs.dir
find . -regextype posix-extended -regex ".*-[[:digit:]]{3}x[[:digit:]]{3}.(jpg|png)" -type f -exec rm {} ;

After deleting the resized media images, now you should regenerate the sizes you do need by using Regenerate Thumbnails or AJAX Thumbnail Rebuild.

Be Sociable, Share!

Related Entries

About Michael Cannon

Hello, I'm Michael Cannon, Peichi's smiling man, an adventurous water-ratchief technology officer, cyclist, poet, WWOOF'er and world traveler.

Previous post:

Next post: