Change the quality of your WordPress thumbnails

Do you think that your cropped thumbnails don’t have a good enough quality? By default, the jpeg quality is set to 90 out of 100 in WordPress – a good balance between performance and looks. Here is how to increase it to max quality, or close to it, depending on what you want.

Add this to your theme’s functions.php:

/*  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' );

Change 100 to anything you want. 95 would be the step inbetween default quality and max quality.

This code also works with images being resized via the new WP_Image_Editor class that was released with WordPress 3.5.

Leave a Reply

Your email address will not be published. Required fields are marked *