I'm using WP CLI wp media regenerate
to resize my thumbnails.
I've noticed something a bit weird. The original image I upload is a JPEG with a resolution (DPI) of 72. The images that are generated have a resolution of 96.
Is this something WordPress core is doing?
Here's what I'm seeing via Tools > Site Health > Media Handling
Here are the image sizes defined via Settings > Media
- Thumbnail: 150 x 150
- Medium Size: 300 x 300
- Large Size: 1200 x 668
And then via my functions, I have the following image sizes defined:
function mytheme_add_custom_image_sizes() {
add_image_size('landscape-large-1x', 600, 334, true);
add_image_size('landscape-large-2x', 1200, 668, true); // Largest image available
add_image_size('landscape-medium-1x', 450, 251, true);
add_image_size('landscape-medium-2x', 900, 502, true);
add_image_size('landscape-small-1x', 384, 214, true);
add_image_size('landscape-small-2x', 768, 428, true);
add_image_size('landscape-smallest-1x', 324, 180, true);
add_image_size('landscape-smallest-2x', 648, 360, true);
add_image_size('square-1x', 96, 96, true);
add_image_size('square-2x', 192, 192, true);
}
add_action('after_setup_theme', 'mytheme_add_custom_image_sizes');
It's also worth mentioning, that I have the following image adjustments via functions.php:
/**
* Remove srcset width limitation
*/
function mytheme_remove_max_srcset_image_width($max_width) {
return false;
}
add_filter('max_srcset_image_width', 'mytheme_remove_max_srcset_image_width');
/**
* Remove default images sizes
*/
function mytheme_remove_default_image_sizes($sizes) {
unset($sizes['1536x1536']); // Introduced in WP 5.3
unset($sizes['2048x2048']); // Introduced in WP 5.3
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'mytheme_remove_default_image_sizes');
/**
* Remove large "scaled" images
*/
add_filter('big_image_size_threshold', '__return_false');
wp_image_editors
filter. And I said so because with GD (where the image editor class isWP_Image_Editor_GD
), the default image DPI is 96.