The handling of big images has been in controversy for a long time among users and developers of WordPress. This happens because there are two types of images that are uploaded:

  • Images that have been edited or created in an image editing application.
  • Photos that are uploaded either directly from the camera or haven’t been edited.

In the first scenario, the images may have been already optimized for usage on the web, but in the second scenario, we often see big images (much bigger) than needed and are not ready for web use. Imagine a photo taken from a smartphone. Its average file size would be easily over 5MB. Imagine what is happening with photos taken from DSLR cameras.

WordPress handling of big images

Here comes WordPress 5.3 that introduces a new way to manage large images by detecting them and generating a “web-optimized maximum size” of them.

How it works

Every time we upload a new image, WordPress will detect if this image is a big one by checking its dimensions. If image dimensions are bigger than big_image_size threshold it will be scaled down, ti the threshold being used as max-height and max-width value. The new scaled-down image will be used as the largest available size.

Now the original image file is stored in the uploads directory and its name will be pushed in another array key. The image meta array: original_image. Also, a new function will be able to get the path to the original image.

wp_get_original_image_path()

Note that the default big_image threshold value is 2560px both for width and height.

Ability to disable the handling of big images

The scaling is controlled by the big_image_size_threshold action. We can disable the filter callback by making it return false.

apply_filters( 'big_image_size_threshold', false );

WordPress Support Services

Tired of slow WordPress hosting or your support is lacking?
We do things different at BakemyWP.

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *