Adjusting WordPress Image Compression

October 6, 2015
Posted in: Code Snippets, Web Development, WordPress

One of the nicer features of WordPress is automatic image resizing – you can upload an image right from your 20 megapixel digital camera, and display it to your users in a predefined web-friendly size.

During the resizing process, WordPress adjusts the uploaded image’s quality by running a compression algorithm on it. Luckily, we can apply a filter to increase or decrease the output quality. Add this code to your theme’s functions.php file, and change the 100 to your desired setting.


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

Setting the quality to 100 might mean that you have big beautiful images, but keep in mind that this will affect your overall page speed. Running selective image optimization will allow you to keep the large images at high quality, while shrinking thumbnails for shorter load times.

Scott Buckingham

President / Owner
613-801-1350 x101
[email protected]
Scott is a WordPress expert who has worked on hundreds of web design and development projects. He excels at finding creative ways to solve technical problems. View full profile