How to Increase or Decrease Default WordPress JPEG Image Compression

WordPress

Images are an important part of blogs and websites. It affects SEO in different ways. It is recommended to use images in blog posts with proper alt and title tags. If you are not sure why you should read how to do image SEO. Adding images in a blog post is necessary, but you should also know that WordPress has a default compression process for images we upload.

WordPress has built-in support to compress images so that they take less space on your web hosting. It also helps to increase the load time of your blog. If you want it to compress images, you can increase or decrease this compression depending on your need. By default, WordPress automatically compresses images at 90% quality. But you can change the quality according to your need. If you are a photographer and using WordPress to show your photographs gallery, compression will result in

Best Managed WordPress Hosting

WPEngine is the best and most secure managed hosting provider

By default, WordPress automatically compresses images at 90% quality. But you can change the quality according to your need. If images are just for representational, and it does not matter if the quality is slightly down, you can reduce this compression to keep your blog posts faster. Load time affects SEO. So, you will be improving the SEO of your blog by doing this. I also recommend you read how to speed up a WordPress blog.

If you are a photographer and using WordPress to show your photographs gallery, compression will result in a loss of photo quality. So, you can change the compression ratio to get better-quality photos after uploading.

By default, WordPress automatically compresses images at 90% quality. But you can change the quality according to your need. If you are a photographer and using WordPress to show your photographs gallery, compression will result in a loss of photo quality. So, you can change the compression ratio to get better-quality photos after uploading.

There is nothing complicated if you want to change the compression of images. You only need to add a single line of code in your theme’s functions.php file. If you want this only for a specific plugin, add the code only within the plugin.

Increase Default WordPress JPEG Image Compression

To keep it on the best quality, change this number to 100.

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

Decrease Default WordPress JPEG Image Compression

To decrease the compression, just reduce the number. You should not change it to less than 50. Others, you will see the very bad quality of images on your blog.

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

Setting the 100 in the code means, WordPress will compress the image at the highest quality. 100 is recommended only for photographers who want their best photos to be uploaded. We can change the value from 70-100. Using a value of less than 60 will result in a loss of quality of images.

In this way, you can change the compression of images and control the quality of images.

When you change the compression setting, it only applies to new images you will now upload. It won’t affect previous images. If you want to optimize previous images, I have already written an article on Image optimization plugins. You can also regenerate thumbnails of existing images using the Regenerate Thumbnails plugin.

Try this code and let me know if it works for you. Do not forget to leave your comment and share this post with friends.


Deepanker Verma is an experienced WordPress developer who has been working on WordPress for more than 12 years. On TheWPGuides, he writes about WordPress, WordPress development, and WordPress plugins.


Similar Articles

0 Comments

Leave a comment

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.

© 2022 The WP Guides Developed By Deepanker