I usually use images on my most of clients the maximum size of 1400px, and never used the medium_large image size for my clients except when the client forces to use. Then when I give the access to client, he may be sometime upload very large image which we don’t needed, so I use the below snippet to disable un-needed image sizes which wordpress generates for each uploaded file. Put this in any code-snippet plugin or functions.php file.
I use Scripts organizer with the below settings :
Note: If you have already have some images uploaded, then these image sizes are not deleted automatically.
<?php
// Remove WP 'medium_large' SIZE
add_filter( 'intermediate_image_sizes', function( $sizes )
{
return array_filter( $sizes, function( $val ) {
return 'medium_large' !== $val;
});
});
// Remove 2x-medium-large and 2x-large SIZES
add_filter( 'intermediate_image_sizes', 'remove_default_img_sizes', 10, 1);
function remove_default_img_sizes( $sizes ) {
$targets = ['1536x1536', '2048x2048'];
foreach($sizes as $size_index=>$size) {
if(in_array($size, $targets)) {
unset($sizes[$size_index]);
}
}
return $sizes;
}
?>