I've read the following article https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images and a number of similar resources.
I can't get my head around why - from a programatic perspective - there is any difference between Art Direction and Resolution Switching. The explanation given for both differs, as does the HTML used to solve the problem. Quoted from the article:
Art direction: The problem whereby you want to serve cropped images for different layouts... This can be solved using the
<picture>element.
and:
Resolution switching: The problem whereby you want to serve smaller image files to narrow screen devices, as they don't need huge images like desktop displays do This can be solved using vector graphics (SVG images), and the
srcsetandsizesattributes.
Let's say I have a "landscape" banner such as a 2000 * 500px image, e.g. http://placehold.it/2000x500
That looks fine on a desktop/laptop screen. But on mobile it doesn't look correct because the content in the centre (text in this case, but could be a photo of a group of people) isn't visible. So I'd imagine this is an example of the art direction problem? But it also falls into the category of resolution switching because why would anyone want to download a 2000px wide image - with a large file size - onto a mobile device when a smaller one could work?
So in terms of the implementation, I could use EITHER the Art Direction or Resolution Switching implementation to solve it? Why do I need 2 different solutions that do the same thing?
For example -
<img srcset="banner-320w.jpg 320w,
banner-480w.jpg 480w,
banner-2000w.jpg 800w"
sizes="(max-width: 320px) 280px,
(max-width: 480px) 440px,
800px"
src="banner-2000w.jpg" alt="Banner">
This would use the banner-2000w.jpg banner on anything over 800px wide, e.g. desktop/laptop and different proportion images (solving the art direction problem) but also of different file sizes (solving the resolution switching problem).
But the exact same thing can also be done with the picture attribute which is what the article describes as a solution for the Art Direction problem:
<picture>
<source media="(max-width: 320px)" srcset="banner-320w.jpg">
<source media="(max-width: 480px)" srcset="banner-480w.jpg">
<img src="banner-2000w.jpg" alt="Banner">
</picture>
Can someone explain under what circumstances one implementation is better than the other? It seems to me that both implementations solve both problems - or is this not the case?