Skip to content

Instantly share code, notes, and snippets.

@jarednova
Created July 27, 2013 17:32
Show Gist options
  • Save jarednova/6095599 to your computer and use it in GitHub Desktop.
Save jarednova/6095599 to your computer and use it in GitHub Desktop.
Twig / Timber if/else
{% if post.thumbnail %}
<img src="{{post.thumbnail.src}}" />
{% elseif post.heroimage %}
<img src="{{post.heroimage.src}}|resize(300, 300)" />
{% else %}
<img src="/wp-content/themes/mytheme/default-image.jpg" />
{% endif %}
@jarednova
Copy link
Author

You can read the Twig docs on conditionals:
http://twig.sensiolabs.org/doc/tags/if.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment