If you upload very large images to your WordPress website, they will automatically be scaled, and the smaller versions will be used inside your posts or pages.
While this might be useful for most WordPress users, some advanced users might be looking to disable the automatic scaling, especially if they have an image management solution in place already (and know what they are doing).
Among many other defined image sizes, WordPress automatically generates medium, 1536×1536, and large 2048×2048 scaled sizes for ‘big’ image uploads, which might often be unnecessary for many users. This happens when you upload images with ‘big image size threshold’, which is 2560px as default.
In this post, I will walk you through how to disable image scaling in WordPress so that you don’t have to see the “-scaled” at the end of your file when you upload large images.
Steps to Disable Scaling Large Images in WordPress
You can stop this automatic behavior of scaling images in WordPress with a single line of code. We will be adding a filter to an existing function that enables this behaviour.
Follow these simple steps to manually edit the functions.php file of your file and add the required code. If you use any code snippets management plugin, that might be the best option instead of editing code directly.
Step 1: Locate the Functions.php File:
Open the functions.php file of your theme using FTP or the WordPress admin area.
Navigate to Appearance > Theme File Editor in the WordPress admin and select Theme Functions (functions.php).
Step 2: Add the Filter Code:
Paste the following code at the bottom of the functions.php file:
add_filter( 'big_image_size_threshold', '__return_false' );
Ensure that the code appears before the closing PHP tag if it exists.
Step 3: Save Changes:
Click on the Update File button to save the changes to the functions.php file.
You have now effectively disabled image scaling in WordPress, allowing you to upload and use large images without any automatic resizing.
While the above code would have solved your problem already, follow along to understand how the image scaling works and the reason why it’s there in the first place.
Disable Image Scaling with Plugins
As with anything in WordPress, there’s no shortage of plugins that can help you disable this auto image scaling feature.
If you are using any kind of media management or image compression plugins, you might first want to check if the feature is built in already.
Here are some of the popular plugins used by other WordPress users to deal with this issue.
Disable Media Sizes Plugin
The Disable Media Sizes By Jeff Starr allows you to disable all the extra images generated by WordPress.
Install the plugin from your dashboard or by downloading it from the WordPress plugin repository.
Activate it and go to the plugin settings page. You will see the options to disable all auto-generated image sizes, including;
- Disable Thumbnail Sizes
- Disable Medium Sizes
- Disable Large Size
- Disable Medium Large (768px)
- Disable 1536×1536 Size
- Disable 2048×2048 Size
- Disable Big/Scaled Sizes
Perfect Images Plugin
This Perfect Images plugin does much more than just disabling automatic scaled images. If you are looking for a complete image sized management solution, this might be useful for you.
Again, Install the plugin from your WordPress dashboard or download it from the WordPress plugin repository to give it a try.
Among many other Image sizing features, the plugin lets you disable the scaled image sizes that WordPress generated automatically;
- disable the medium_large, 1536×1536,
- and large size 2048×2048
The plugin also lets you optimise images and manage other image tasks such as replacing images, regenerating thumbnails and more.
Image Sizes Generated in WordPress
If you have played with your media settings, you might have seen some options for defining image sizes.
WordPress allows you to choose settings for image sizes, including Thumbnail size, Medium size, and Large size.
You can find these settings defined in the Media Settings, as shown in the screenshot below.
While it’s great to have control over these media settings, there are a few sizes that WordPress automatically generates behind the scenes, which we have tried to tackle in this post.
These are the additional image sizes “big” (scaled) size images that WordPress generates quietly behind the scenes and appends “-scaled” to your image names.
- medium-large (768px) Size images
- 1536×1536 Size images
- 2048×2048 Size Images
As these sizes aren’t covered in the default media settings screen, we have to use additional plugins or code to change the behaviour.
Now, let’s deep dive into how these auto settings work and the rationale behind them in the section below.
How does Image Scaling work in WordPress?
With the feature introduced in version 5.3, WordPress automatically scales uploaded images that exceed a predefined threshold to optimize website performance and improve user experience. Here’s how it works:
When a new image is uploaded, WordPress checks if its height or width exceeds a predefined threshold, currently set at 2560 pixels by default. This threshold can be modified using the ‘big_image_size_threshold
‘ filter.
If the image dimensions exceed the threshold, it is scaled down using the threshold as the maximum height and width. This scaled-down version becomes the largest available size, while the original, full-sized image is stored in the uploads directory with its file name saved in the ‘original_image
‘ key of the image metadata array.
To retrieve the path to the original, full-sized image, WordPress provides the ‘wp_get_original_image_path()
‘ function. This allows developers and users to access the original image, even though it’s not directly used as the displayed image on the website.
The image scaling feature aims to strike a balance between maintaining image quality and optimizing website performance.
Should you disable Scaled Images?
It’s hard to deny that the feature is fantastic for users who directly upload images without having to resize, as WordPress is able to handle it automatically.
However, if you know what you are doing and have your images optimised already, you don’t have to depend on WordPress to create an additional-sized image for you.
There might also be situations where you actually need to use the original-sized images, and there’s no point in letting WordPress make additional copies for you. They might even end up taking a lot of extra disk space if they are not required for your website.
In conclusion, WordPress’s image scaling feature is useful for most users. It allows them to optimize website performance and improve user experience by creating smaller, more manageable versions of large images.
However, if you are an advanced user who has your own image management solution or needs to use original, full-sized images, you can disable the automatic image scaling feature and take control of it.
With the right approach, you can ensure that your website’s images are optimized without compromising the quality or your specific requirements.
code works fine, thank you