{% extends "documents/base.html" %}
{% load i18n %}
{% load thumbnail pagination_tags %}

{% block titleextra %}{% trans "Cover images" %}{% endblock %}

{% block content %}
<div class="card mt-4 mb-4">
	<div class="card-header">
<h1>{% trans "Cover images" %}{% if only_unused %} (nieużywane){% endif %}</h1>
	</div>
	<div class="card-body">

          <div class="mb-4">
            {% if can_add %}
              <a class="btn btn-primary" href="{% url 'cover_add_image' %}">{% trans "Add new" %}</a>
            {% endif %}
            {% if only_unused %}
              <a class="btn btn-secondary" href=".">
                Pokaż wszystkie
              </a>
            {% else %}
              <a class="btn btn-secondary" href="?unused=1">
                Pokaż tylko nieużywane
              </a>
            {% endif %}

          </div>
<div class="row">
{% autopaginate object_list 100 %}
{% for image in object_list %}
<div class="col-md-3">
<div class="card">
  <a href="{{ image.get_absolute_url }}">
    {% if image.file %}
	<img style="height: 100px; width: auto;" class="card-img-top" src="{% thumbnail image.file "x100" as thumb %}
                {{ thumb.url }}
             {% empty %}
                {{ image.file.url }}
             {% endthumbnail %}" />
    {% endif %}
    <div class="card-body">
      {{ image }}
    </div>
  </a>
</div>
</div>
{% endfor %}
</div>

{% paginate %}
	</div>
</div>

{% endblock %}
