% removable = local_assigns.fetch(:removable, false)
image_size = local_assigns.fetch(:image_size, [200, 200]) %>
<% if attachment.image? and attachment.variable? and !field.url_only? %>
<%= image_tag attachment.variant(resize_to_limit: image_size), class:"avatar-img rounded"%>
<% elsif attachment.image? and !field.url_only? %>
<%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
<%= image_tag(field.url(attachment)) %>
<% end %>
<% elsif attachment.video? and attachment.previewable? and !field.url_only? %> <%# if ffmpeg is installed %>
<%= video_tag(field.url(attachment), poster: field.preview(attachment, resize_to_limit: image_size), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
<% elsif attachment.video? and !field.url_only? %>
<%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
<% elsif attachment.audio? and !field.url_only? %>
<%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
<% else %>
<%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
<% if attachment.previewable? and !field.url_only? %>
<%= image_tag(field.preview(attachment, resize_to_limit: [595, 842])) %>
<% else %>
<%= attachment.filename %>
<% end %>
<% end %>
<% end %>
<% if removable %>
<%#= link_to 'Remove', field.destroy_path(field, attachment), method: :delete, class: 'remove-attachment-link' %>
<%= link_to 'Remove', destroy_url,
method: :delete,
# data: { confirm: t("administrate.actions.confirm") },
remote: true,
class: 'remove-attachment-link'
%>
<% end %>