<picture>
HTML element can help with art directing a particular graphical area of a page.
<picture>
HTML element: loading completely different images altogether based on screen size.
srcset
attribute should be used.x
descriptor should be used after the image file URL. This helps with loading higher resolution images for monitors with higher DPI.media
attribute should be used to indicate multiple breakpoints.Completely different images are loaded via the <picture>
HTML element, resize this page to see the image on the left change.
<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>
<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>