Created
June 27, 2018 12:32
-
-
Save joe-dempsey/054405855f53ff069c2156335a9204ed to your computer and use it in GitHub Desktop.
shopify blog show first available image if no featured image
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
{% if article.image.size > 0 %} | |
# show featured image | |
{% else %} | |
{% if article.content contains "<img" %} | |
{% assign src = article.content | split: 'src="' %} | |
{% assign src = src[1] | split: '"' | first %} | |
<img src="{{ src }}" alt="{{ article.title }}"> | |
{% endif %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment