Skip to content

Instantly share code, notes, and snippets.

@sinan
Last active December 20, 2017 17:58
Show Gist options
  • Save sinan/c6fc17cf0bc4fde2f6e0bce750fb6623 to your computer and use it in GitHub Desktop.
Save sinan/c6fc17cf0bc4fde2f6e0bce750fb6623 to your computer and use it in GitHub Desktop.
a workaround for showing responsive images in hubspot
# 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