Skip to content
Field note

Remove & Resize WordPress Images

Introduction

June 29, 2016·1 min read·Michael Cannon, Director of Intelligent Automation/ Field correspondent
Remove & Resize WordPress Images

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.

Companion brief

Bring this dispatch into a working session - one page in, scoping memo out.

Brief Foyer
Pressure-test "Field note" with a partner

If this dispatch landed, bring it into a room with us.

The argument in "Remove & Resize WordPress Images" is ours - but every situation breaks the argument differently. Send the situation in one page and a named partner will reply inside one business day with a scoping memo: where the argument holds for you, where it bends, and what we'd actually do in the first two weeks.

One-pager · Field note

By submitting this form you acknowledge that you have read Axelerant's Privacy Policy and agree to its terms.

Replied to by a named partner within one business day.