Using the intermediate_image_sizes_advanced
filter was not working for me. However, the intermediate_image_sizes
works and the $default_sizes
array is an indexed array, not an associative array. In every single example that I have found for using the intermediate_image_sizes_advanced
filter, the answer’s are unsetting the image sizes from an associative array.
The following worked for me in WP 5.3:
add_filter( 'intermediate_image_sizes', 'remove_default_img_sizes', 10, 1);
function remove_default_img_sizes( $sizes ) {
$targets = ['medium', 'medium_large', 'large', '1536x1536', '2048x2048'];
foreach($sizes as $size_index=>$size) {
if(in_array($size, $targets)) {
unset($sizes[$size_index]);
}
}
return $sizes;
}
Here’s a link to the function that adds the two additional sizes since 5.3 with an explanation to why I was able to remove them using remove_image_size
.