Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.