One of our users, a photographer, complained that the JPEG image he uploaded were losing a little bit of quality. After doing some research, we found out that it is true that WordPress does automatically compress JPEG images at 90% quality. In this article, we will show you how to increase or decrease WordPress JPEG image compression.
All you need to do is paste the following code in your theme’s functions.php file or your site-specific plugin.
add_filter('jpeg_quality', function($arg){return 100;});
Setting it to 100 would mean that WordPress would compress the image at its highest quality. For most users, this is not an issue. Heck, we never noticed it on our site. But if you are a photographer, then this is noticeable (we suppose).
There are definitely performance benefits to leaving the compression quality as is. If you want, you can change the number from 100 to 80 or something lower to squeeze a few more kBs.
Source: Glyn Mooney







Thanks for this, just what I needed.
m.
Hi, i want to know if I can config wordpress to compress all types of images, not only jpeg. is it possible?
Hi there, i’m using Twitter Bootstrap for WordPress and when I add this code ‘add_filter(‘jpeg_quality’, function($arg){return 100;});’ into the theme it says there’s an error. What could I be doing wrong?
Works with php 5.3 or newer. For older versions you should use:
add_filter( ‘jpeg_quality’, create_function( ”, ‘return 100;’ ) );
as the reference says:
http://codex.wordpress.org/Function_Reference/add_filter
How to change JPEG images quality with different value of % for the different auto-generated image sizes (ex full->90%, thumb->60%)? Thanks!
Not sure if that is even possible. Will have to look into the core.
its great knowledge concerns…..thanks for it.
before using this code, i face some problem about the layout of images………
now its good…