<ul class="thumbnails">

{% for pic in gallery_pictures %}
{% with pic.GetCaption as caption %}
<li class="{{thumb_size}}">
<a class="gallery-image" rel="gallery-{{ gallery_id}}" href="{{ pic.picture.resized.url }}"
    {% if caption %} title="{{caption}}" {% endif %}>
    <img class="thumbnail" src="{{ pic.picture.thumbnail.url }}" alt="{{ caption }}" />
  </a>
</li>
{% endwith %}
{% endfor %}
<script>
  $("a.gallery-image").fancybox({
    'speedIn' : 100,
    'speedOut' : 100,
    'titlePosition' : 'inside',
    'cyclic' : true,
  });
</script>

</ul>
