Skip to content

Instantly share code, notes, and snippets.

@zachharkey
Created August 15, 2013 03:59
Show Gist options
  • Save zachharkey/6238157 to your computer and use it in GitHub Desktop.
Save zachharkey/6238157 to your computer and use it in GitHub Desktop.
This one allows me to upload an image to the assets folder to server as the thumbnail for each subcategory (aka tag). So for example, if my main collection is "books", and my tags are "fiction, nonfiction, biography", the code spits out a list of all tags with those titles, AND images with the URL: http://YOUR-STORE-CDN-URL/books-fiction.jpg, ht…
<div class="clearfix image-subcats">
<!-- Begin image subcats -->
{% if settings.collection_tags %}
{% capture col_url%}{% if collection.url.size == 0 %}/collections/all{%else%}{{collection.url}}{%endif%}{%endcapture%}
{% if collection.all_tags.size > 0 %}
{% for tag in collection.all_tags %}
<div class="product span3">
<div class="image">
<a href="{{col_url}}/{{tag | handle}}">
{% capture file_name %}{{ collection.handle }}-{{ tag | handle }}.jpg{% endcapture %}
{% capture alt_attr %}{{ collection.title | escape }}-{{tag | handle}}{% endcapture %}
{{ file_name | asset_url | img_tag: alt_attr }}
</a>
</div>
<h3>{{ tag | link_to_tag: tag }}</h3>
</div>
{% endfor %}
{% endif %}
{% endif %}
<!-- End image subcats -->
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment