Prevent WordPress from rendering large images small (“scaled”)

Prevent Wordpress from rendering large images small (“scaled”)

Prevent Wordpress from rendering large images small (“scaled”) – Screenshot/Montage T.Bortels/cpu20.de

Since version 5.3 “large images” are automatically re-rendered by WordPress – i.e. rendered small – and provided with the note “scaled” in the file name. This can be useful to avoid that too large images are delivered to the users. So the intention is good at first. But what is well-intentioned does not always have to be good. What is a “large image” from the point of view of WordPress? From 2560px an image is considered a “large image” for WordPress.

If you build your WordPress theme yourself, you want to have full control – especially over the size of the images displayed. The feature that automatically reduces the size of the images and adds the note “scaled” to the file name then seems more like a bug.

To avoid this problem, you can switch off this new function manually. However, if possible, you should implement the corresponding adjustment right at the beginning, before too much content or images have been uploaded to the server. Otherwise you may spend a lot of time uploading the images again.

Deactivate scaling function big_image_size_threshold

To deactivate the function you just have to insert the following code snippet into the functions.php and the spook has an end:

// Prevent WordPress from Scaling Large Images
add_filter( 'big_image_size_threshold', '__return_false' );

This feature is now disabled.

As I said: it is best to implement this filter before you start uploading lots of large images. Otherwise you will have to upload all large images again afterwards.

Alternatively, you could also define the limit from which images are considered or treated as large images. For example, if you want images with a page length of 4800px or more to be considered “large”, you can insert the following code snippet into functions.php:

/**
 * Increases the threshold for scaling big images to 4800.
 * In this case all the images that are larger than 4800px (width or height) 
 * will be scaled to 4800px.
 *
 * @param $threshold
 * @return int
 */
function hff_big_image_size_threshold( $threshold ) {
	return 4800; // new threshold
}
add_filter('big_image_size_threshold', 'hff_big_image_size_threshold', 100, 1);

Here is the page for the function at make.wordpress.org/core/ …