WordPress will compress images uploaded to your site by 10%, meaning that the quality of your images will be 90% of their original quality after you upload them. You might not want your images to be compressed at all, or you may want to compress them further. In the examples below we’ll show you how to remove compression entirely or how to adjust the level to something more appropriate to the requirements of your website.

Photo by JESHOOTS.COM on Unsplash
Stop Auto Compression of Images
On a website that makes use of high quality images you may want to keep these at full quality. For a photographer, illustrator or graphic designer for example, image quality may be preferred over saving space and performance. You can achieve this by adding the code below to your functions file. The first filter sets the quality of jpeg’s to 100%. The second filter does the same thing but for all images. The reason we are using both in this example is because the wp_editor_set_quality filter is superseded by the jpeg_quality filter, so by setting both filters we’re hitting all image types:
//stop auto compression of images add_filter('jpeg_quality', function($arg){return 100;}); add_filter( 'wp_editor_set_quality', function($arg){return 100;} );
Compress your Images Further
On the flip side you might like the idea of compressing your images further, to save space on your hosting platform and improve performance. You might not need your images to be particularly high in quality. In this case you can adjust the levels however you like. In the example below we’ve set the quality of our images to 75%:
//adjust auto compression of images add_filter('jpeg_quality', function($arg){return 75;}); add_filter( 'wp_editor_set_quality', function($arg){return 75;} );
Regenerate Thumbnails
If you have existing images that were uploaded prior to changing the level of compression then you’ll probably want to regenerate these. You can do this with the Regenerate Thumbnails plugin by Alex Mills.
Comments
Whether you have feedback, a question, want to share your opinion, or simply want to say thank you - we welcome comments! Please read the disclaimer.