WP 4.4 aspect ratio with responsive image

How to make new WP responsive image to choose images by filename and add them to srcset without checking aspect ratio?

I have my own sizes:

add_image_size( 'l', 992, 500, array( 'center', 'center' ) );
add_image_size( 'm', 768, 500, array( 'center', 'center' ) );
add_image_size( 'sm', 450, 300, array( 'center', 'center' ) );

And I want to use them in srcset.

1 Answer
1

You shouldn’t.

srcset is used for when you want to optimise the quality for different devices by serving different sizes of the same image. If you want to serve different crops, you should be using the picture element instead.

For example, if the intention of your image sizes is to serve a ‘small’ version to ‘mobile’ devices, using srcset won’t achieve that. For example, an iPhone 6, despite only being 414px wide, would serve your large 992×500 image due to being 3x retina quality.

Leave a Comment