{% extends 'entity/page.html.j2' %}
{% set file = file | default(entity) %}
{% set page_title = file.description %}
{% block page_content %}
    {% if file.media_type and file.media_type.type == 'image' %}
        <div class="featured image">
            <a href="{{ file | file | static_url }}">
                <img src="{{ file | image((1500, 1500)) | static_url }}"{% if file.description %} alt="{{ file.description }}"{% endif %}>
            </a>
        </div>
    {% endif %}
    {% with notes = file.notes %}
        {% include 'section-notes.html.j2' %}
    {% endwith %}
    {% set entities = file.entities | select('public') | list %}
    {% if entities | length > 0 %}
        <section id="appearances">
            <h2>
                {% trans %}Appearances{% endtrans %}
                {% with url = page_resource | url ~ '#appearances'%}
                    {% include 'permalink.html.j2' %}
                {% endwith %}
            </h2>
            <ul class="entities">
                {% for entity in entities %}
                    <li class="{{ loop.cycle('odd', 'even') }}">
                        {% include ['entity/label--' + entity.plugin_id() + '.html.j2', 'entity/label.html.j2'] %}
                        {% include ['entity/meta--' + entity.plugin_id() + '.html.j2', 'entity/meta.html.j2'] ignore missing %}
                    </li>
                {% endfor %}
            </ul>
        </section>
    {% endif %}
    {% set citations = file.citations | list %}
    {% if citations | length  > 0 %}
        {# These are the citations for the file itself. This assumes no other citations are tracked on the page and #}
        {# rendered by base.html.j2. #}
        <section id="references">
            <h2>
                {% trans %}References{% endtrans %}
                {% with url = page_resource | url ~ '#references'%}
                    {% include 'permalink.html.j2' %}
                {% endwith %}
            </h2>
            <ul>
            {% for citation in citations %}
                <li>{% include 'entity/label--citation.html.j2' %}</li>
            {% endfor %}
            </ul>
        </section>
    {% endif %}
{% endblock %}
