Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image media is creating a new image size of 768px but how do I stop it?

After updating to WordPress 4.5 I was doing a media upload test and I noticed that I was generating a new image size that I cannot figure out how to stop.

The current function I am using to prevent generating multiple sizes of my media is:

function add_image_insert_override( $sizes ) {
    unset( $sizes[ 'thumbnail' ]);
    unset( $sizes[ 'medium' ]);
    unset( $sizes[ 'large' ]);
    unset( $sizes[ 'full' ] );
    return $sizes;
}
add_filter( 'intermediate_image_sizes_advanced', 'add_image_insert_override' );

How can I stop WordPress 4.5 from generating images with a width of 768px?

like image 374
DᴀʀᴛʜVᴀᴅᴇʀ Avatar asked May 22 '16 02:05

DᴀʀᴛʜVᴀᴅᴇʀ


1 Answers

I didn't find this anywhere other than the article I referenced under Responsive Images in WordPress 4.4 when they indicated that a new image size had been created:

A new default intermediate size, medium_large, has been added to better take advantage of responsive image support. The new size is 768px wide by default, with no height limit, and can be used like any other size available in WordPress. As it is a standard size, it will only be generated when new images are uploaded or sizes are regenerated with third party plugins.

After reading this article I was then able to update my function to:

function add_image_insert_override( $sizes ){
    unset( $sizes[ 'thumbnail' ]);
    unset( $sizes[ 'medium' ]);
    unset( $sizes[ 'medium_large' ] );
    unset( $sizes[ 'large' ]);
    unset( $sizes[ 'full' ] );
    return $sizes;
}
add_filter( 'intermediate_image_sizes_advanced', 'add_image_insert_override' );

Now when I add media to a post I am no longer generating foobar-768xwhatever. Hope this helps the next person.

like image 100
DᴀʀᴛʜVᴀᴅᴇʀ Avatar answered Nov 03 '22 18:11

DᴀʀᴛʜVᴀᴅᴇʀ