I am using object-fit: cover on a bunch of images. The frame for the image takes up 50vw and has a dynamic height. The cover attribute works great, but it means that I don't really know how wide my actual image will be at a given time.
Most likely it will be wider than the 50vw and will have its overflow hidden due to the object-fit cover.
The problem comes in when I try to use srcset. I am unable to give a reliable width for the sizes attribute.
I know that size only needs an approximation, but I am curious if anyone has dealt with this before.
Not sure, but this is what I do for almost all my dynamic images:
I make a
<div>and make it whatever size I want, and set the image inline as the bg of the div (cause most templating langs you cant set in CSS).