<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=278116885016877&amp;ev=PageView&amp;noscript=1">

, , , ,

Jun 29, 2016 | 1 Minute Read

Remove & Resize WordPress Images

Table of Contents

Introduction

When we change our WordPress themes, we often forget that default image sizes have changed too. As most plugins to resize WordPress images don't remove the current resized images, our wp-content/uploads or wp-content/blog.dir directories become full of abandoned images resulting in wasted disk space.

The command lines below will remove current resized images, including Retina versions so that we can correctly resize WordPress images per the new theme dimensions. And yes, we're using the command line, because I (Michael) am old school.

SHOW all resized images

[code]cd /home/example/public_html/wp-content/uploads
find . -regextype posix-extended -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -type f
cd /home/example/public_html/wp-content/blogs.dir
find . -regextype posix-extended -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -type f[/code]

DELETE all resized images

[code]cd /home/example/public_html/wp-content/uploads
find . -regextype posix-extended -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -type f -exec rm {} \;
cd /home/example/public_html/wp-content/blogs.dir
find . -regextype posix-extended -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -type f -exec rm {} \;[/code]

Rebuild to Resize WordPress Images

After deleting the resized media images, we can regenerate the sizes needed by using the Regenerate Thumbnails or AJAX Thumbnail Rebuild WordPress plugins.

This article was originally written in September 2011 and has been updated since for clarity.

About the Author
Michael Cannon, Chief Success Officer
About the Author

Michael Cannon, Chief Success Officer

Adventurous pegan water-rat, Drusus & Jace's smiling baba, social impact photographer.


Back to Top