Smarter Handling of Large Images in WP 5.3
I was pleasantly surprised to learn about this WordPress 5.3 feature which in highlighted by Justin Ahinon on Make WordPress Core. The issue it’s meant to solve is an uncompressed 12 megapixel fresh-from-the-phone type of photo being comically too large for your WordPress site.
In my playing with the WordPress media APIs I’ve never loved, but none of this looks like it’d cause obvious probelms:
When a new image is uploaded, WordPress will detect if it is a “big” image by checking if its height or its width is above a
big_image threshold. The default threshold value is 2560px, filterable with the new
If an image height or width is above this threshold, it will be scaled down, with the threshold being used as max-height and max-width value. The scaled-down image will be used as the largest available size.
In this case, the original image file is stored in the uploads directory and its name is stored in another array key in the image meta array:
original_image. To be able to always get the path to an originally uploaded image a new function