Skip to content

Instantly share code, notes, and snippets.

@tonydieu
Created October 15, 2015 07:32
Show Gist options
  • Save tonydieu/8c1e4ea3e1eca1ecd2ff to your computer and use it in GitHub Desktop.
Save tonydieu/8c1e4ea3e1eca1ecd2ff to your computer and use it in GitHub Desktop.
ligthbox shopify blog
<div>
{% if article.content contains "<img" %}
{% assign content-src = article.content | split: 'src="' %}
{% assign content-size = content-src.size | minus:1 %}
{% for i in (1..content-size) %}
{% assign src = content-src[i] | split: '"' | first | replace: '//cdn', 'http://cdn';;; | replace: 'http:http://';;;, 'http://';;; | remove: 'https:' %}
<a href="{{src}}" data-lightbox="{{article.id}}">
{% if i == 1 %}
<img src="{{src}}"/>
{% endif %}
</a>
{% endfor %}
{% else %}
{% endif %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment