Add, Remove, Change and Regenerate Image Sizes in WordPress

Images play a big role in every website, be it a blog, magazine or any other type. Each theme/design uses different size of images for thumbnails and even in-post images. By default, WordPress has 3 images sizes. These are as follows: thumbnail, medium and large. The size of these can be edited under settings->media. But besides these, in most cases, the theme you use adds several different image sizes based on how the theme is made.

In this article, I’ll talk about how you can add additional image size in WordPress, how you can remove them if you don’t need them and also how to regenerate these images if you change your theme or install a plugin that adds additional image sizes.

Editing the Default Images Size

The first thing I’ll show you is how you can edit the size of the 3 default image sizes that are built into WordPress. As I mentioned above, go to settings -> media there you’ll be presented with the following page, where you can manually set the height and width of these image size.

If you edit these settings and save them, your currently uploaded images won’t change sizes. Only the ones you’ll upload after these settings were saved. In order to change the size of the already uploaded images to the new size, you’ll need to regenerate them. Which I’ll talk about a bit later in this article.

How to Check the Current Image Sizes

To check all the image sizes your site currently have, you need to install a plugin called Display All Image Sizes


Then, when you add/edit an image in a post, look at the “size” dropdown, and it’ll display all the current image sizes you have.

How to Remove the Default Images Size

In case you for what ever reason, want to remove these default image size. ( NOT recommended ) You can add the following PHP Snippet into your theme’s functions.php file.

function paulund_remove_default_image_sizes( $sizes) {
    unset( $sizes['thumbnail']);
    unset( $sizes['medium']);
    unset( $sizes['large']);
     
    return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'paulund_remove_default_image_sizes');

Source: Paulund.com

Another method is to set the width and height of the images sizes to 0 (zero).

Doing this can be very dangerous. As when you add images to your posts and pages, WordPress uses these 3 image sizes. And if you delete them, you will end up with broken images in your posts and pages.

In case you made this change and you want to change it back, simply remove the PHP code or if you used the other method, set the image size width and height back to the original, 150px, 300px and 1024px.

Remove Image Sizes Add by Themes/Plugins

Even thou this is not recommended, some themes end up having like 5-6 image sizes, from which you only use like 2, max 3. The rest of the images are only there to occupy space. To remove some of these image sizes, you can use the remove_image_size() WordPress function. Don’t forget to replace the “custom-image-size1” with the size you want to remove.

You can find the image sizes using the method I’ve shown you above.

function remove_image_sizes() {
    if ( function_exists( 'add_image_size' ) ) { 
        remove_image_size( 'custom-image-size1');
        remove_image_size( 'custom-image-size2');
     }
}
add_action('after_setup_theme', 'remove_image_sizes');

More information on remove_image_size

Another and preferred method would be to go through your theme’s files and search for the add_image_size() functions and remove them that way.

Adding Additional Image Sizes

If you want to add different Image sizes then the ones that your theme currently adds, you can use the following code in a site-specific plugin, or your theme’s functions.php

function add_image_sizes() {
    if ( function_exists( 'add_image_size' ) ) { 
        add_image_size( 'custom-image-size1', 300, 9999 ); //300 pixels wide (and unlimited height)
        add_image_size( 'custom-image-size2', 220, 180, true ); //(cropped)
    }
}
add_action('after_setup_theme', 'add_image_sizes');

More information on add_image_size

Keep in mind, the with each image size you add, one extra image will be created for each of your current ones. So if you have 100 images for example, and you add 1 more image size, you’ll end up with 200 images. So be careful how many sizes you add.

Regenerating Images

Regenerating your images helps and is a must if you changed your site’s theme for example. In most cases, each theme uses different image sizes by default, and if you change your theme, the ones from your old theme might not fit the new one. If this is the case, you’ll want to regenerate your image sizes.

To regenerate the image size, you’ll need one of these plugins:

Force Regenerate Thumbnails

How this plugin works, is it deleted all the extra images, leaving only the main image file that you uploaded. Then it scans your files for additional image sizes, and it creates new images based on those sizes. The process can take from minutes to hours depending on how many images you have.

Regenerate Thumbnails

This one works similarly, but instead of deleting the old images, it keeps them.

You’ll need to use this each time you add/remove image sizes from your WordPress install.

Conclusion

Even thou WordPress makes it very easy to add/remove image sizes, it’s not something you would want to mess around too much with. Because it can damage your site, imagine if you have 200 or only 100 posts, and you remove the default image sizes. All those posts will have broken images in them. How long will it take for you to fix that? A long time and broken images also effect your visitors, and with that, your site’s reputation.

I hope this article helps you understand how to add/remove/change image sizes in WordPress. If you have any questions, suggestions, feel free to leave a comment down below.

Get more stuff like this

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Add Comment

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.