Media

Stop WordPress Compressing JPEG Images

Compress

Whenever you upload an image to WordPress media library it will automatically compress your images to 90% quality, this is to size a bit of bandwidth on displaying images on your web page.

But if your a photographer and you want to always have the highest quality images on your site then you can change the default compression to 100% quality. All you have to add the following to your functions.php file, this will run when compressing your images and return the value of the quality you want.

add_filter('jpeg_quality', function($arg){return 100;});
add_filter( 'wp_editor_set_quality', function($arg){return 100;} );
Back to top

Learn how to code with Treehouse

  • Learn projects with access to 1000+ videos
  • Practice live with our Code Challenge Engine
  • Get help in our members-only forums

Start with a 7 day free trial