How to fix the quality of thumbnails in WordPress?

Hello. The problem with the quality of the miniatures. After creating a thumbnail image of all pixels.

Create thumbnail like this:
add_image_size('thumb_370', 370, 277, array( 'left', 'top' ));
If the image is long, the bottom is clipped. That is, if the original 1000x1000px, it width will be 370, and the length will be clipped to 277.

Deduce this:
<img src="<?= get_the_post_thumbnail_url($post->ID, 'thumb_370')?>" alt="<?= get_the_post_thumbnail_caption()?>">


I tried this code to remove the compression quality doesn't help.
add_filter( 'jpeg_quality', create_function( ", 'return 100;' ) );
April 4th 20 at 13:15
1 answer
April 4th 20 at 13:17
Solution

I tried this code to remove the compression quality doesn't help.
add_filter( 'jpeg_quality', create_function( ", 'return 100;' ) );


Doing everything right.

Only after that you must regenerate thumbnails. For this there are a lot of plugins, for example here is one of them.

UPD:
More modern code would look like this:
add_filter( 'jpeg_quality', 'filter_function_name_11' );
filter_function_name_11 function( $quality ) { 
 return 100;
}

Find more questions by tags WordPress