You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following our <Image /> component, create a <Picture /> component that can have different art direction props at different media sizes (aspect ratios, and crop regions).
Current Reality
I'm not sure how to do this today outside of making your own component. A raw HTML version would look like this.
<picture><sourcesrcset="https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=2000&height=2524&crop=center 2000w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=2200&height=2776&crop=center 2200w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=2400&height=3029&crop=center 2400w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=2600&height=3281&crop=center 2600w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=2800&height=3534&crop=center 2800w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=3000&height=3786&crop=center 3000w" media="min-width: 60em"><sourcesrcset="https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=1000&height=1262&crop=center 1000w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=1200&height=1514&crop=center 1200w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=1400&height=1767&crop=center 1400w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=1600&height=2019&crop=center 1600w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=1800&height=2272&crop=center 1800w" media="min-width: 80em"><imgalt="Tracks in the snow leading to a person on a mountain top with a red jacket contrasting to an epic blue horizon with a mountain range in the distance." decoding="async" height="126.2" loading="eager" src="https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=100&height=126&crop=center" srcset="https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=200&height=252&crop=center 200w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=400&height=505&crop=center 400w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=600&height=757&crop=center 600w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=800&height=1010&crop=center 800w, https://cdn.shopify.com/s/files/1/0551/4566/0472/files/Hydrogen_Hero_Feature_1.jpg?v=1654902468&width=1000&height=1262&crop=center 1000w," width="100" class="block object-cover w-full h-full" style="width:100%;aspect-ratio:2500/3155"></picture>
The non-obvious problems
Creating your component forces you only to be able to use top/left/right/bottom/center crop regions — focal_point is not possible
If you have a hero image that is aspect ratio 16/9 on desktop, but 1/1 on mobile, and you use object-fit: cover to get it to look right, you're loading in a lot of excess pixels on the screen,
In addition to point 2, you don't have the ability to art direct the cropping
The text was updated successfully, but these errors were encountered:
Following our
<Image />
component, create a<Picture />
component that can have different art direction props at different media sizes (aspect ratios, and crop regions).The DX would be something like this…
Current Reality
I'm not sure how to do this today outside of making your own component. A raw HTML version would look like this.
The non-obvious problems
top
/left
/right
/bottom
/center
crop regions —focal_point
is not possible16/9
on desktop, but1/1
on mobile, and you useobject-fit: cover
to get it to look right, you're loading in a lot of excess pixels on the screen,The text was updated successfully, but these errors were encountered: