Skip to content

Instantly share code, notes, and snippets.

@zachharkey
Created August 15, 2013 04:06
Show Gist options
  • Select an option

  • Save zachharkey/6238187 to your computer and use it in GitHub Desktop.

Select an option

Save zachharkey/6238187 to your computer and use it in GitHub Desktop.
{% assign src = false %}
{% if article.content contains "<img" %}
{% assign src = article.content | split: 'src="' %}
{% assign src = src[1] | split: '"' | first | replace: '//cdn', 'http://cdn';; | replace: 'http:http://';;, 'http://';; | remove: 'https:' %}
{% comment %}
Let's assume you always add images to the blog as large.
{% endcomment %}
{% if src %}
{% assign src = src | replace:'_large','_icon' %}
{% endif %}
<img src="{{ src }}" alt="article.title" />
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment