Skip to content

Instantly share code, notes, and snippets.

@carbone carbone/snippet.liquid Secret
Last active Jun 4, 2018

Embed
What would you like to do?
strip liquid image preserve tag
If the alt tag is empty...
{% if product.metafields.custom_fields["test_background_image"] contains 'alt=""' %}
{% assign image_url = product.metafields.custom_fields["test_background_image"] | remove: '<img src="' | remove: '" alt="" typeof="foaf:Image" />' %}
Image URL: {{ image_url }}
{% else %}
If the alt tag has a value...
{% assign v1 = product.metafields.custom_fields["test_background_image"] | remove: '<img alt="' | split: '" src="'%}
{% assign alt = v1[0] %}
{% assign image_url = v1[1] | remove: '" typeof="foaf:Image" />'%}
Image URL: {{ image_url }}
Alt Tag: {{ 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.