Remove Default Image Thumbnail Sizes in WordPress

How to Remove Default Image Thumbnail Sizes in WordPress

in Media
Google+ LinkedIn

When you upload an image to WordPress, it automatically crops uploaded image to a number of extra sizes. By default, WordPress generates three different sizes Thumbnail, Medium Size and Large Size. You can take benefit of these different size auto generated images by using them on different sections of your website. For example you can use Medium size images on homepage but Thumbnail size for archive pages. It’s quite useful.

If you have defined custom image sizes in your theme and don’t plan to use any of these default thumbnail sizes then you might want to stop WordPress from auto generating these default images sizes. By disabling this feature you can save on excess server processing along with space on the hard drive. Some people prefer to have separate thumbnail size images but it’s not always necessary. You can remove these from being used by using the WordPress action intermediate_image_sizes_advanced and unset the thumbnail, medium and large sizes, this will mean the only size they have left is the full image size.

To remove default image thumbnail sizes, simply paste this code snippet in your theme’s functions.php file.

// remove default image thumbnail sizes in wordpress
function wcs_remove_default_image_sizes( $sizes) {
    unset( $sizes['thumbnail'] );
    unset( $sizes['medium'] );
    unset( $sizes['large'] );
    return $sizes;
}
add_filter( 'intermediate_image_sizes_advanced', 'wcs_remove_default_image_sizes' );

Alternatively you can also set width and height of Thumbnail, Medium Size and Large Size to zero to remove default image thumbnail sizes. It also works but unsetting sizes is better solution.

// remove default image thumbnail sizes in wordpress
update_option( 'thumbnail_size_h', 0 );
update_option( 'thumbnail_size_w', 0 );
update_option( 'medium_size_h', 0 );
update_option( 'medium_size_w', 0 );
update_option( 'large_size_h', 0 );
update_option( 'large_size_w', 0 );

Share the love

If you like this snippet, share it with others!

Leave a Reply

Your email address will not be published. Required fields are marked *