19Jul

WordPress create scaled files bigger than original file from large image > 2560px

A client asked me why uploading a large image in the WordPress media library would create a scaled image. This scaled down image is heavier than the original image (when optimised for the web). Here is how to deactivate scaled image in WordPress.

Always compress your images before to upload them to the CMS.

Before uploading any image to the WordPress media library, I recommend using TinyPNG. (tip: Look at the desktop third-party software to save you time)

Doing that, the designer discovered the image saved for the web with a larger pixel dimension was lighter than the WordPress resized scaled-down image with the suffix “_scaled” once uploaded in the CMS.

test.jpg with 2880px and 107kb in size became test_scaled.jpg with 2560px and is 347kb in size. Not great!!

This is linked to the function “big_image_size_threshold” introduced with WordPress 5.3.0 https://developer.wordpress.org/reference/hooks/big_image_size_threshold/ 

This happens for images larger than 2560px. As the document says: “The threshold value in pixels. Default 2560.

How to deactivate scaled image in WordPress

This is the bit of code you can add to the function.php file inside your active WordPress theme.

add_filter( 'big_image_size_threshold', '__return_false' );
function filter_image_sizes( $sizes) {
	unset( $sizes['1536x1536']); // disable 2x medium-large size
	unset( $sizes['2048x2048']); // disable 2x large size
	return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes');

You don’t need this scaled function if you save your images for the web properly.

Hope that can help someone!

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments