{% extends "wagtailadmin/widgets/chooser.html" %}
{% load embed_video_tags wagtailimages_tags %}

{% block chooser_class %}embed-video-chooser{% endblock %}

{% block chosen_state_view %}
    <div class="preview-image">
        {% if embed_video %}
            {% if embed_video.thumbnail %}
                {% image embed_video.thumbnail max-130x130%}
            {% else %}
                {% video embed_video.url as my_video %}
                    <img src="{{ my_video.thumbnail }}" style="max-width: 130px; max-height: 130px;">
                {% endvideo %}
            {% endif %}
        {% else %}
            <img>
        {% endif %}
    </div>
{% endblock %}

{% block edit_chosen_item_url %}{% if embed_video %}{% url 'wagtail_embed_videos_edit_embed_video' embed_video.id %}{% endif %}{% endblock %}
