{% load embed_video_tags wagtailimages_tags wagtailadmin_tags %}
{% load i18n %}
{% if embed_videos %}
    {% if is_searching %}
        <h2 role="alert">
        {% blocktrans count counter=embed_videos.paginator.count %}
            There is {{ counter }} match
        {% plural %}
            There are {{ counter }} matches
        {% endblocktrans %}
        </h2>
    {% else %}
        <h2>{% trans "Latest videos" %}</h2>
    {% endif %}

    <ul class="listing horiz images chooser">
        {% for embed_video in embed_videos %}
            <li>
                <a class="image-choice" title="{% if collections %}{{ embed_video.collection.name }} » {% endif %}{{ embed_video.title }}" href="{% url 'wagtail_embed_videos:embed_video_chosen' embed_video.id %}">
                    <div class="image">
                        {% if embed_video.thumbnail %}
                            {% image embed_video.thumbnail max-165x165 class="show-transparency" %}
                        {% else %}
                            {% video embed_video.url as my_video %}
                                <img src="{{ my_video.thumbnail }}" class="show-transparency" style="max-width: 165px; max-height: 165px;">
                            {% endvideo %}
                        {% endif %}
                    </div>
                    <h3>{{ embed_video.title|ellipsistrim:60 }}</h3>
                </a>
            </li>
        {% endfor %}
    </ul>

    {% include "wagtailadmin/shared/ajax_pagination_nav.html" with items=embed_videos %}
{% endif %}
