{% extends "@templates/"~template~"/view/base.html.twig" %}

{% block meta %}{{ getMeta(currentGallery) }}{% endblock %}

{% block javascript %}
{{ parent() }}
<script src="{{ asset('media/Public/vendor/lightbox/dist/js/lightbox.min.js') }}"></script>
{% endblock %}

{% block content %}
<div class="grid-container">
    <div class="grid-x wi-gallery-details">
        <div class="cell">
            <h1>{{ currentGallery ? currentGallery.title : 'Galeria zdjęć' }}</h1>
            {% if currentGallery is not null %}
                <div class="wi-gallery-content">{{ currentGallery.content|raw }}</div>
            {% endif %}
        </div>
    </div>
    {% if galleries|length > 0 %}
    <div class="grid-x wi-gallery-galleries">
        {% for gallery in galleries %}
            {% set image = gallery.cover ? gallery.coverUrl : (gallery.photos.count > 0 ? gallery.photos.first.photo('thumbnailS') : 'media/Public/img/album-placeholder.jpg') %}
            <div class="large-3 medium-4 small-6 wi-gallery">
                <div class="wi-gallery-photo">
                    <div class="wi-gallery-photo-inner">
                        <a href="{{ url('wi_front_gallery_album', { 'id': gallery.id, 'slug': slugify(gallery.title) }) }}" title="{{ gallery.title }}" class="wi-thumbnail-inner">
                            {% if image %}
                                <img src="{{ asset(image) }}" alt="{{ gallery.title }}">
                            {% endif %}
                        </a>
                    </div>
                </div>
                <h3><a href="{{ url('wi_front_gallery_album', { 'id': gallery.id, 'slug': slugify(gallery.title) }) }}" title="{{ gallery.title }}">{{ gallery.title }}</a></h3>
            </div>
        {% endfor %}
    </div>
    {% endif %}
    <div class="grid-x wi-gallery-photos">
        {% for photo in photos %}
            <div class="large-3 medium-4 small-6 wi-gallery-photo">
                <div class="wi-gallery-photo-inner">
                    <a href="{{ asset(photo.photo) }}" title="{{ photo.title }}" data-lightbox="lightbox" class="wi-thumbnail-inner">
                        <img src="{{ asset(photo.photo('thumbnailS')) }}" alt="{{ photo.title }}">
                    </a>
                </div>
            </div>
        {% endfor %}
    </div>
</div>
{% endblock %}
