JPEG Compression in WordPress

Some users doesn’t know about JPEG compression in WordPress. When we upload an image to media library it automatically compress to 90% of quality. It will decrease the size of file so to load the site even faster.

The compression of 90% by default will not affect to image as you see. But for photographer or someone who like to show image with full quality. For those there is a WordPress function to manage the quality of uploading image. you can set the quality as parameter.

Following is the code to manage the quality that you have to add in theme’s functions.php:
add_filter('jpeg_quality', function($arg){return 100;});
add_filter( 'wp_editor_set_quality', function($arg){return 100;} );

As I said before by default value set to 90, to use full quality of JPEG image we can override to 100 by this function. Also you can increase the compression rate by adding 80 or 85 as return value. Which helps to decease the image size we uploading so page will load fast.

Free plugin to manage compression quality

For this if you don’t like to edit theme file functions.php. Then you can use free plugin WP Resized Image Quality/ to manage the compression.

When plugin installed and activated, a slider will add to Settings -> Media page to change the quality of uploading image.

After code added or change plugin settings it will affect only to uploading images. To add this change to existing images on the media library we have to use Regenerate Thumbnails plugin. After install the plugin run it by Tools -> Regenerate Thumbnails. Now all the images in the media library quality changed to new quality we saved.

Note: This image quality compression only for JPEG format images. WordPress doesn’t currently support PNG compression internally.

About the author

Vinu Narayanan

I am a freelance web developer, travel addict and work-in-progress human being based in Kerala, India. I have 5 years of experience in Wordpress and I love to work in this CMS.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Copyright © 2016. Created by Vinu Narayanan with Love.

Get Email Updates!

We send out our lovely email newsletter weekly with useful tips and techniques, and recent articles. Get Connected!
Email address