Use Case: Art Direction The <picture> HTML element can help with art directing a particular graphical area of a page. Important Notes: When to use just the image element: loading different resolutions of the same image based on screen size. When to use the <picture> HTML element: loading completely different images altogether based on screen size. The srcset attribute should be used. The x descriptor should be used after the image file URL. This helps with loading higher resolution images for monitors with higher DPI. The media attribute should be used to indicate multiple breakpoints. For more advanced use cases, reference the MDN article on responsive images. Demo
Alt text.

Completely different images are loaded via the <picture> HTML element, resize this page to see the image on the left change.

Twig
<picture> // Set the image sources <source srcset="path/image-2x.jpg 2x, path/image.jpg" media="(min-width: 1000px)"> <source srcset="path/image-b-1200.jpg 2x, path/image-b-600.jpg" media="(min-width: 600px)"> <source srcset="path/image-a-600.jpg 2x, path/image-a-300.jpg" media="(min-width: 300px)"> // Set the fallback image {% include '@bolt-elements-image/image.twig' with { attributes: { alt: 'Alt text.', src: 'path/image.jpg', srcset: 'path/image-2x.jpg 2x', width: 1000, height: 500, }, } only %} </picture>
HTML
<picture> // Set the image sources <source srcset="path/image-2x.jpg 2x, path/image.jpg" media="(min-width: 1000px)"> <source srcset="path/image-b-1200.jpg 2x, path/image-b-600.jpg" media="(min-width: 600px)"> <source srcset="path/image-a-600.jpg 2x, path/image-a-300.jpg" media="(min-width: 300px)"> // Set the fallback image <img src="path/image.jpg" srcset="path/image-2x.jpg 2x" width=1000 height=500 class="e-bolt-image" alt="Alt text."> </picture>