Increase JPEG Quality in WordPress

0
Want create site? Find Free WordPress Themes and plugins.

Increase JPEG Quality in WordPress

When you upload an image to WordPress it’s processed and compressed to 90% of its original JPEG quality. This is a default setting that’s in place to automatically optimize every image, which in turn can hopefully speed up your site’s loading time.

It’s a nice enough little feature, but the fact that it happens behind the scenes without anyone really knowing it’s going on can cause some users a lot of grief. Especially photographers who see a drop in JPEG quality every time they upload an image.


There’s no option to change this within the WordPress admin and not having the power to control the JPEG quality of your images can be frustrating.

Stop Compressing My Images Already!

As with most features in WordPress, there’s a filter or action in place that we can hook into which will allow us to modify and customize certain functions. For this mod, the filter we need to hook into is called jpeg_quality.

<?php add_filter( 'jpeg_quality', 'bavotasan_custom_jpeg_quality' ); function bavotasan_custom_jpeg_quality( $quality ) { return 100; } ?>

All the filter requires is a quality setting between 1 and 100, with 100 being no compression whatsoever.

You can read a bit about the jpeg_quality filter and see the original function by checking out the code reference page.

Needs More Compression

If you’re someone who believes in the full extent of optimizing your images, then compressing them even more might be the way to go. It’s an easy enough change since all you need to do is decrease the JPEG quality to a setting below the default of 90.

<?php
add_filter( 'jpeg_quality', 'bavotasan_custom_jpeg_quality' );
function bavotasan_custom_jpeg_quality( $quality ) { 
   return 75; 
}
?>

You can always play around with the number and test out the results. You might discover a perfect balance between smaller file size and optimal image quality.

Make it easier on yourself and install the Regenerate Thumbnails plugin so you don’t have to re-upload your images again and again while trying out different quality settings.

If you have any suggestions or comments, please feel free to use the form below to start a discussion.

Featured image provided by Death to the Stock Photo.

The post Increase JPEG Quality in WordPress appeared first on bavotasan.com.

Web Hosting
Did you find apk for android? You can find new Free Android Games and apps.

You might also like More from author

Leave A Reply

Your email address will not be published.