Wordpress - WordPress adding scaled images that don't exist (1536x1536 and 2048x2048)
I found the culprit!
WordPress 5.3 introduced additional image sizes which can be found via /wp-includes/media.php
.
Updating my function, like so, removed the extra sizes:
function remove_default_image_sizes( $sizes) {
unset( $sizes['large']); // Added to remove 1024
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['medium_large']);
unset( $sizes['1536x1536']);
unset( $sizes['2048x2048']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'remove_default_image_sizes');
You could also remove those image sizes completely using remove_image_size
(see: https://developer.wordpress.org/reference/functions/remove_image_size/)
Example (to be placed in your functions.php file):
remove_image_size('1536x1536');
remove_image_size('2048x2048');
This function, however, won't work for default WP image sizes (e.g. 'thumbnail', 'medium', 'large', etc.). There's a work-around though. Simply set the sizes to 0:
update_option( 'thumbnail_size_h', 0 );
update_option( 'thumbnail_size_w', 0 );
update_option( 'medium_size_h', 0 );
update_option( 'medium_size_w', 0 );
update_option( 'medium_large_size_w', 0 );
update_option( 'medium_large_size_h', 0 );
update_option( 'large_size_h', 0 );
update_option( 'large_size_w', 0 );