I have stopped generating multiple image sizes since the aspect ratio property in css picked up browser support. It’s very good way to get the desired aspect ratio without filling up the server storage.
I use the following images sizes generally while removing the default wp sizes. Aspect ratio property with object fit takes care of the rest. Previously I used to generate image sizes for different aspect ratio
@Marius You might also be interested in the below code. I use it to generate webp images for image sizes and it keeps the original (full size) image as jpg/png for backward compatibility with older browsers. Also saves some space on the server and I don’t use any image optimization plugins.
// Retain full size image in original format and make other sizes in webp
function my_wp_image_editor_output_format( $formats ) {
$formats['image/jpeg'] = 'image/webp';
$formats['image/png'] = 'image/webp';
return $formats;
}
add_filter( 'image_editor_output_format', 'my_wp_image_editor_output_format' );
Thanks for this, Louis.
One little tweak still needed - the input box for aspect ratio via the global classes panel is a bit wonky. See below. Would also be nice to have the object-fit parameters editable from the same panel as well.
Not urgent, but thought I’d brought it to your attention.