I want my responsive Webpage to load the appropriately sized images. I currently have an HTML template that looks like:
<picture>
<source media="(min-width: 950px)" srcset="{{ .Cover.Large }}">
<source media="(min-width: 600px)" srcset="{{ .Cover.Medium }}">
<source media="(min-width: 300px)" srcset="{{ .Cover.Small }}">
<source media="(min-width: 150px)" srcset="{{ .Cover.Xsmall }}">
<img src="{{ .Cover.Medium }}" alt="{{ .Title }} poster">
</picture>
Large = 950x400 Medium = 600x252 Small = 300x126 Xmall = 150x63
Now I'm thinking this min-width is not going to work very well if the pictures are in a row or flexed. Isn't it best to define the dimensions of the image and let the browser download the most suitable source?
https://html.spec.whatwg.org/multipage/embedded-content.html#valid-source-size-list
What's the cleanest way to do this? Confusingly in my own responsive experiments, the Large size is always loaded: