Disable wordpress image sizes generation

Question

I’m trying to disable image sizes generation in wordpress.

When I use:

print_r( get_intermediate_image_sizes() );

it shows:

Array
(
    [0] => thumbnail
    [1] => medium
    [2] => medium_large
    [3] => large
    [4] => 1536x1536
    [5] => 2048x2048
)

So i tried:

add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes');
function filter_image_sizes($sizes) {
    unset( $sizes['medium']);
    unset( $sizes['medium_large']);
    unset( $sizes['large']);
    unset( $sizes['1536x1536']);
    unset( $sizes['2048x2048']);
    return $sizes;
});

and

add_filter('intermediate_image_sizes', 'filter_image_sizes');
function filter_image_sizes($sizes) {
    unset( $sizes['medium']);
    unset( $sizes['medium_large']);
    unset( $sizes['large']);
    unset( $sizes['1536x1536']);
    unset( $sizes['2048x2048']);
    return $sizes;
});

but it doesn’t work. Setting values in admin menu doesn’t work too.

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

this work’s, but deletes all image sizes and I want to leave thumbnails..

0
, , , Matredok 3 years 2019-11-22T12:56:49-05:00 0 Answers 126 views 0

Leave an answer

Browse
Browse