Use custom image compression for different image sizes in WP-Optimize on child sites.
Snippet Type
Execute on Child Sites
Snippet
add_filter( 'wpo_image_compression_single_image_options', 'my_prefix_change_image_compression_options', 20, 4 );
function my_prefix_change_image_compression_options( $options, $attachment_id, $file_path, $size ) {
// Set the quality to 80 for the full size images
if ( 'full' == $size ) {
$options['quality'] = 80;
}
// Set the quality to 51 for thumbnails.
if ( 'thumbnail' == $size ) {
$options['quality'] = 51;
}
return $options;
}