Remove WordPress Default Image Sizes

WordPress image sizes contain defaults, small, medium 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

Why you may want to do this could be that you definitely don’t need certain sizes or you are saving on web disk space or have a similar custom image size already created.

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.

You can also remove the srcset responsive images technique that WordPress enagages by using the max_srcset_image_width filter

// Disable WordPRess responsive srcset images
add_filter('max_srcset_image_width', create_function('', 'return 1;'));