Prevent WordPress from generating medium_large 768px size of image uploads?

I prevent WordPress from generating thumbnail, medium, and large image sizes for images I upload to the Media Library, by setting their dimensions to 0 from the dashboard: Settings -> Media panel.

I have also gotten rid of all instances of add_image_size and set_post_thumbnail_size from the functions.php file of my theme.

However, when I upload new images, WordPress is still generating a 768px width version (called ‘medium_large’) from my original full size image. I believe it has something to do with this update.

Is there is any way to prevent this from happening?

3

To remove the medium_large image size you can try to remove it with the intermediate_image_sizes filter:

add_filter( 'intermediate_image_sizes', function( $sizes )
{
    return array_filter( $sizes, function( $val )
    {
        return 'medium_large' !== $val; // Filter out 'medium_large'
    } );
} );

Not sure if you’re trying to remove all the intermediate sizes, but then you could try out:

add_filter( 'intermediate_image_sizes', '__return_empty_array', 999 );

where __return_empty_array()` is a built-in core function.

We should note that it’s not possible to remove it with

remove_image_size( 'medium_large' );

because it’s not added with add_image_size() and therefore not part of the $_wp_additional_image_sizes global array or wp_get_additional_image_sizes();

Leave a Comment