Skip to content

Instantly share code, notes, and snippets.

@dreamalligator
Created January 14, 2014 04:24
Show Gist options
  • Save dreamalligator/8413011 to your computer and use it in GitHub Desktop.
Save dreamalligator/8413011 to your computer and use it in GitHub Desktop.
image snippet for Jekyll
{% comment %}
update image path to your rel path
usage:
{% include image src="post.images[0]" %}
{% include image src="whatnot.jpg" %}
{% endcomment %}
{% assign imgpath="/images/" %}
{% if include.src %}
<img src="{{ imgpath }}{{include.src}}">
{% elsif post.images[0] != NULL %}
{% for image in post.images %}
<img src="{{ imgpath }}{{ post.images[0] }}">
{% endfor %}
{% elsif page.images[0] != NULL %}
{% for image in page.images %}
<img src="{{ imgpath }}{{ image }}">
{% endfor %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment