How to Remove WordPress Default Image Sizes

WordPress image sizes contain defaults, smallmedium and large as well as medium-large which is used in their implementation of responsive images. You can remove these default images with a WordPress filter intermediate_image_sizes_advanced

add_filter( 'intermediate_image_sizes_advanced', 'prefix_remove_default_images' );
// Remove default image sizes here. 
function prefix_remove_default_images( $sizes ) {
 unset( $sizes['small']); // 150px
 unset( $sizes['medium']); // 300px
 unset( $sizes['large']); // 1024px
 unset( $sizes['medium_large']); // 768px
 return $sizes;

So just unset the ones you want, so for existing images nothing will change unless you use Force Regenerate Thumbnail which will remove redundant images – but for new images uploaded they will only take on the sizes which remain set by the filter.

Leave a Reply

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