Black Friday50% off every Pro template and membership with code50% off with Ends in 03days23hrs42min09secShop the sale →

How to Change JPEG Image Compression in WordPress

Do you want to change JPEG image compression in WordPress to improve your site performance? If yes, you have come to the right place. This blog provides you with a useful solution. Now, check it out. Why should you stop…

How to Change JPEG Image Compression in WordPress

Do you want to change JPEG image compression in WordPress to improve your site performance? If yes, you have come to the right place. This blog provides you with a useful solution. Now, check it out.

Why should you stop WordPress from compressing JPEG images?

By default, WordPress Media Library will compress uploaded JPEG images to 90% of their original quality. Since WordPress 4.5, your images are compressed to 82% to boost your site performance.  Although this functionality helps you free up server space, speed up page loading, and save hosting bandwidth, it is not useful for websites that specialize in displaying and providing images such as photography and design websites, because it can make your images lower in quality than you want.

Therefore, it is necessary for you to stop WordPress from compressing JPEG images to maintain the quality of your uploaded images.

How to disable WordPress JPEG image compression

If you would like to retain 100% of your images’ quality after uploading them to the WordPress Media Library, disabling image compression is a great solution.

To do that, simply add the following code to the functions.php file of your theme or in a site-specific plugin.

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

This code will ensure that WordPress will keep the original quality of your image.

How to increase image compression in WordPress

There is no denying that compressing images also gives your website better performance. If your website doesn’t rely on images, you should increase image compression to speed up your site.

You can increase image compression by changing the number from 100 to 80 or even lower. All you need to do is add the following code.

add_filter('jpeg_quality', function($arg){return 75;});

After pasting this code into the functions.php file of your theme, you need to regenerate your thumbnails so that you can see the result of your custom image compression settings in WordPress.

Wrap up

Honestly, changing image compression in WordPress brings many benefits for your website. However, in some situations, you need to prevent WordPress from compressing JPEG images to keep the quality of your images. Hopefully, our blog gave you a useful way to change JPEG image compression in WordPress. If you have any problems, feel free to leave a comment below.

Moreover, you can drop by our website to discover a collection of beautiful, responsive Photography WordPress Themes. They can help you build a successful website. Don’t miss them.

Build it with a template

Start from a finished design: Joomla templates, WordPress themes or the AI-ready block themes. Every template has a free version and a live demo.

Free download

We'll send the link, setup tips and update notices, and you can reach us anytime through our AI assistant and contact form.

The download starts at once. We email you the link and ask you to confirm your address. Privacy policy.