WordPress version 5.3 made a change to the way it handles large images uploaded to the media library. This change was made to help address the issue of very large images being uploaded without first being optimized for the web.
Photos taken with a modern smartphone can be over 5MB in size which is much too large and unnecessary for use on a website.
So to help solve this, WordPress now detects big images and applies a scaling filter. The default threshold is 2560px, and will be applied to both the height and width, and the image will be scaled down. This scaled image will be used as the largest available size.
While this a good feature in general, not everyone will want images scaled. Photographers or artists showing portfolio pieces may want to show bigger images. We show much larger images on our website portfolio over at Spigot: https://spigotdesign.com/work
How to disable the scaling
The scaling feature is controlled by a new filter: big_image_size_threshold
. Disable it by returning false from the filter callback. Add the following to either functions.php
or a custom functions plugin:
add_filter( 'big_image_size_threshold', '__return_false' );
Change scaling threshold
If you prefer to change the threshold value instead of disabling, use this instead:
function cinch_image_threshold($imagesize, $file, $attachment_id){
return 1920;
}
add_filter( 'big_image_size_threshold', 'cinch_image_threshold',10,3 );
Does this still work?
I think this is just the beginning of WordPress attempting to help website owners manage images better. Let me know in the comments if you run into issues of if these scripts stop working.
8 Comments
Hi,
this doesn’t work anymore. Neither the snippet for removing the threshold nor the one to adjust it do anything.
I haven’t heard that this filter hook has been deprecated. What is the basis of your theory?
It works! Thank you so much!
Okay great to hear Jay, thanks for chiming in! A previous commenter stated that it no longer works, and I had yet to test. Cheers.
I just tried this and it works. I now have a lot of images to upload and attach to portfolios. Thank you very much!
Awesome, glad to hear it works Carole!
Hi! This may solve a problem I’m having with image resolution, but what will it do for page load times? I have a client whose using large images of gardens (he’s a garden designer). He sends me HUGE images. I reduce pixel size, then compress, and the image looks good…until it gets into the slider. Even then, some are better than others. I’m on a staging site at the moment, link included. Thanks, Bryan! Best wishes, Valerie
Hi Valerie,
Disabling the WP scaling feature and posting larger images will certainly have a negative affect on load time. If you’re struggling with image optimization I wouldn’t use this filter to solve that issue.
I checked the link you posted but couldn’t see the sliders. If you want me to take a closer look, jump on a chat during our business hours (8-6 Mountain time) and I should be able to give you some guidance.