KrisChase.com

Set WordPress image quality to high

Posted in Web Development on 06.10.2015 by @chasebadkids

Did you know that by default, WordPress smushes your JPG images down to 60% quality after your upload them?

You can circumvent this by editing your themes functions.php file and adding the following snippet.

Please note: You will sacrifice speed for quality but in doing so you will get 100% image quality on every upload.

/*  Custom thumbnail quality
/* ------------------------------------ */
function alx_thumbnail_quality( $quality ) {
    return 100;
}
add_filter( 'jpeg_quality', 'alx_thumbnail_quality' );
add_filter( 'wp_editor_set_quality', 'alx_thumbnail_quality' );

If you’ve already got a lot of images in your media library you’ll have to re-upload them in order to get that original image quality.  While doing so, why not add a few custom WordPress image sizes for your themes use?

What projects have you used this snippet on?  Share your results below!

Menu