{% load i18n fb_versions %}
{% with field.value as value %}

{% if value and value.exists %}
    {% if value.filetype == "Image" %}
    {% version value.path 'admin_thumbnail' as thumbnail_version %}
        {% if thumbnail_version %}
        <p class="preview" id="preview_{{ final_attrs.id }}">
            <a href="{{ value.url }}" target="_blank" id="previewlink_{{ final_attrs.id }}">
                <img id="previewimage_{{ final_attrs.id }}" src="{{ thumbnail_version.url }}" class="preview" />
            </a>
        </p>
        {% else %}
        <p class="preview" id="preview_{{ final_attrs.id }}" style="display: none;">
            <span id="previewlink_{{ final_attrs.id }}">
                <img id="previewimage_{{ final_attrs.id }}" class="preview" src="" />
            </span>
        </p>
        {% endif %}
    {% else %}
        <p><a href="{{ value.url }}">{{ value }}</a></p>
    {% endif %}
{% else %}
<ul class="errorlist"><li>{% trans "File not found" %}</li></ul>
{% endif %}
{% endwith %}