Last active
December 20, 2017 17:58
-
-
Save sinan/c6fc17cf0bc4fde2f6e0bce750fb6623 to your computer and use it in GitHub Desktop.
a workaround for showing responsive images in hubspot
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
# in your custom module you can create two images | |
# e.g. widget.image and widget.image2x | |
# then use them in a responsive img tag as below. | |
# basic idea | |
{% if widget.image.src %} | |
<img src="{{ widget.image.src }}" srcset="{{ widget.image.src }} 1x, {{ widget.image2x.src }} 2x" /> | |
{% endif %} | |
# cleaner version | |
{% if widget.image.src && widget.image2x.src %} | |
<img src="{{ widget.image.src }}" srcset="{{ widget.image.src }} 1x, {{ widget.image2x.src }} 2x" /> | |
{% else if widget.image.src %} | |
<img src="{{ widget.image.src }}" alt="{{ widget.image.alt }}"> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment