Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created February 14, 2012 20:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fredgrott/1830171 to your computer and use it in GitHub Desktop.
Save fredgrott/1830171 to your computer and use it in GitHub Desktop.
twitterbs_image_helper
{% comment%}<!--
Be careful we do not want to access or iterate an array as an associative
array of associative arrays
We are cheating here by using
assign siteImgArrayObject to tell us what associative array to iterate over
out of collection of associative arrays.
for example:
img:
baseImgURL: img
fileName: ['','']
href: ['','']]
The first loop run
items.baseimgURL[1] = something
items.fileName[2] = an image filename
items.href[3] = is a href
loop run two
items.baseImgURL[1]= nothing
items.fileName[2] = an image filename
items.href[3] = is an href
Syntax:
{% assign siteImgArrayObject = 'site.img' %}
{% assign target = '_blank' %}
{% include FG/twitterbs_image_helper %}
-->{% endcomment%}
{% if site.FG.twitterbs_image_helper.provider == "custom" %}
{% include custom/twitterbss_image_helper %}
{% else %}
<ul class="thumbnails">
{% if siteImgArrayObject %}
{% if site.target %}
{% for items siteImgArrayObject %}
{$ if items.baseImgURL[1] %}{% assign imgBaseURL='{{ BASE_URL }}/{{ items.baseimgURL[1] }} %}{% endif %}
<li class="span2">
<a href="{{ items.href[2] }}" class="thumbnail" target="{{ site.target }}">
<img src="{{ site.imgBaseURL }}/{{ items.fileName[1] }}.png" alt="">
</a>
</li>
{% endfor %}
{% endif %}
{% else %}
{% for images siteImgArrayObject %}
{$ if items.baseImgURL[1] %}{% assign imgBaseURL='{{ BASE_URL }}/{{ items.baseImgURL[1] }} %}{% endif %}
<li class="span2">
<a href="#" class="thumbnail" >
<img src="{{ site.imgBaseURL }}/{{ items.fileName[1] }}.png" alt="">
</a>
</li>
{% endfor %}
</ul>
{$ endif %}
{% assign imgBaseURL = nil %}
{% assign target = nil %}
{% assign siteImgArrayObject = 'nil' %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment