{% extends "widgets/ajax_fileinput.html" %}

{% block before_filedata %}
{%- if field.show_thumbnail %}
<div class="thumbnail-container">
  <img class="thumbnail" src="{{ value.url if value else '' }}" class='value'
       {%- if field.retina and field.size %} style="max-width: {{ field.size[0]//2 }}px"{% endif %}
       {%- if not value %} style="display: none"{% endif %}/>
  {%- if field.size and field.fill_from and field.crop %}
    <a class="button icon-crop compact-button"
       {%- if not value %} style="display: none"{% endif %} title="Кадрировать">Кадрировать</a>
  {% endif %}
</div>
{%- endif %}
{% endblock %}

{% block extra_js_options %}
  data-image="true"
  {#data-canvas-thumb-preview="{{ 'true' if field.canvas_thumb_preview else '' }}"#}
  {%- if field.crop_url is defined and field.crop_url %}
    data-crop-url="{{ field.crop_url }}"
  {% endif %}
  {%- if field.thumb_size %}
    data-thumb-width="{{ field.thumb_size[0] }}"
    data-thumb-height="{{ field.thumb_size[1] }}"
  {%- endif -%}
  {%- if field.size and field.fill_from and field.crop %}
    data-crop="true"
    data-fill-from="{{ field.fill_from }}"
    data-crop-width="{{ field.size[0] }}"
    data-crop-height="{{ field.size[1] }}"
  {%- endif -%}
{% endblock %}
