combo/combo/apps/gallery/templates/combo/gallerycell.html

35 lines
1.1 KiB
HTML

{% load thumbnail %}
{% block cell-content %}
<div class="gallery" id="gallery-{{cell.id}}">
{% for image in cell.image_set.all %}
{% if forloop.first %}
{% thumbnail image.image "640x480" crop="50% 25%" as im %}
<div class="main-image">
<img src="{{ im.url }}" title="{{ image.title }}"/>
</div>
<div>
{% endthumbnail %}
{% endif %}
{% thumbnail image.image "60x60" crop="50% 25%" as im %}
{% thumbnail image.image "640x480" crop="50% 25%" as im_large %}
<a data-image-large="{{ im_large.url }}" class="image-switch"><img src="{{ im.url }}"
{% if image.title %} title="{{image.title}}" {% endif %}/></a>
{% endthumbnail %}
{% endthumbnail %}
{% endfor %}
</div>
</div>
<script type="text/javascript">
$(function() {
var $gallery = $('#gallery-{{cell.id}}');
$gallery.find('.image-switch').on('click', function() {
$gallery.find('div.main-image img').attr('src', $(this).data('image-large'));
var $title = $(this).find('img').attr('title') || '';
$gallery.find('div.main-image img').attr('title', $title);
return false;
});
});
</script>
{% endblock %}