Created
January 23, 2018 13:37
-
-
Save 1aurabrown/0fe3ac4438b29fe5379e7852589dec89 to your computer and use it in GitHub Desktop.
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
{% comment %} | |
Responsive images with srcset. | |
{% endcomment %} | |
{% assign default_default_size = "480x" %} | |
{% assign default_sizes = "100vw" %} | |
{% if default_size == nil %}{% assign default_size = default_default_size %}{% endif %} | |
{% if sizes == nil %}{% assign sizes = default_sizes %}{% endif %} | |
<img src="{{ image.src | img_url: default_size }}" | |
srcset=" | |
{{ image.src | img_url: '50x' }} 50w, | |
{{ image.src | img_url: '100x' }} 100w, | |
{{ image.src | img_url: '160x' }} 160w, | |
{{ image.src | img_url: '240x' }} 240w, | |
{{ image.src | img_url: '480x' }} 480w, | |
{{ image.src | img_url: '600x' }} 600w, | |
{{ image.src | img_url: '1024x' }} 1024w, | |
{{ image.src | img_url: '2048x' }} 2048w" | |
sizes="{{ sizes }}" | |
alt="{{ image.alt | escape }}" | |
data-js-responsive="true" | |
{% if attributes != nil %}{{ attributes }}{% endif %} | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment