Created
July 1, 2021 14:53
-
-
Save craigcooperxyz/2afe06546575b1bf2733004c737a5e63 to your computer and use it in GitHub Desktop.
Picture element for images in Shopify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign image = image %} | |
<picture> | |
<source srcset="{{ image | img_url: '335x', format: 'pjpg'}}, {{ image | img_url: '670x', format: 'pjpg' }} 2x" | |
media="(max-width: 375px)"> | |
<source srcset="{{ image | img_url: '750x', format: 'pjpg'}}, {{ image | img_url: '1500x', format: 'pjpg' }} 2x" | |
media="(max-width: 749px)"> | |
<source srcset="{{ image | img_url: '1500x', format: 'pjpg' }}" | |
media="(min-width: 750px)"> | |
<img src="{{ image | img_url: '1500x', format: 'pjpg' }}" alt="" | |
srcset="{{ image | img_url: '1500x', format: 'pjpg' }}"> | |
</picture> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
format: 'pjpg'
where not appropriate, particularly if using transparent PNGs