How to Change WordPress JPEG Image Compression

If you own a website then you must be aware of the fact that how important are the images on your site. This importance is even higher for the e-commerce websites and all those kind of websites which demonstrate their products through images. Images give your visitors a brighter idea of the product and keep the visitors engaged on your website. You need to put high-quality images to make it more convincing. But, there is a problem with these high-quality photos, they make your site load slowly. Most of the users are more likely to leave your site if takes more than a few seconds to load despite their interest in the product.

WordPress takes care of this fact and compresses the images automatically to enhance the performance of your website. Whenever you upload a JPEG image it is compressed by 90% of its quality by WordPress automatically. Although, in WordPress 4.5 it is set to 82 percent because of the increasing number of mobile users.

No doubt this image compression improves the performance of your site but if you are some who is more interested in showcasing the images then it may not be a favorable thing to you. However, WordPress is highly flexible and customizable, it allows you to stop this automatic image compression.

Disabling Image compression in WordPress:

It is extremely easy to disable the image compression in WordPress. You only need to add a simple line of code in the function.php file of your theme. You can copy paste below given code to the function.php file of your theme for this purpose.

add_filter(‘jpeg_quality’, function($arg){return 100;});

Here you have set the quality value to 100 which means WordPress will no more compress the image and you will get the maximum possible quality.
You may not be much bothered about the quality of an image until and unless you are an artist or a photographer. Those who are interested in high-quality images will look for the minor details os the image.

Moreover, if you want to set a balance of the quality and performance then you have to change the compression value some value where it can give a fair quality without much impact on loading speed.

Changing the Image Compression Value in wordPress:

Now you are well aware of the fact that Image compression will improve the speed and a high-quality image will lead to a slow loading site. If you want to compress the images to some extent so that quality remains these but not at the cost of performance. You can set the value somewhere in between, yes WordPress provides you this freedom as well.

It is again a supremely easy task. Just paste the following code into your theme’s function.php file:
add_filter(‘jpeg_quality’, function($arg){return 70;});

In this way, you can set the quality value to your desired percentage. Always keep in mind that this will be applicable for only new images and WordPress will not resize images you have already uploaded before applying these changes. In case you want to resize the old images and regenerate thumbnails, you may need to use a plugin.

So now you know how to have a control of the quality of images on your WordPress website and you can use this handy information to maximize your benefits. If you are concerned about the speed then compress the image and if concerned about the quality then set the desired value for the quality, how flexible is that? It may be even more beneficial for you if you are a developer or a designer who has to deal with a number of websites. It will help you to make changes according to different needs of different clients.

How to Change WordPress JPEG Image Compression
Rate this post

Leave a Reply