<%# # Item Partial This partial renders attached items. Attachments of type image, video and audio are emedded. For all other types we try use it's preview. If all else fails we simply link to the attached file. This partial will optionally show a `remove` link next to each attachment which is controlled via a boolean local variable. ## Local variables: - `field`: An instance of [Administrate::Field::Image]. A wrapper around the image url pulled from the database. - `attachment`: Reference to the file - `removable`: A boolean used to control the display of a `Remove` link which is used to destroy a single attachment. Defaults to `false` %> <% # By default we don't allow attachment removal removable = local_assigns.fetch(:removable, false) image_size = local_assigns.fetch(:image_size, [1920, 1080]) %> <% if attachment.image? and attachment.variable? and !field.url_only? %> <%#= link_to(field.blob_url(attachment), title: attachment.filename) do %> <%#= image_tag(field.variant(attachment, resize_to_limit: image_size)) %> <%#= link_to(field.blob_url(attachment), title: attachment.filename, class:'avatar avatar-sm mr-2') do %> <%#= image_tag attachment, class:"avatar-img rounded-circle" %> <%#= link_to(field.blob_url(attachment), title: attachment.filename, class:'avatar avatar-sm mr-2') do %> <%#= image_tag(field.variant(attachment, resize_to_limit: image_size, quality: 100, :loader => {strip: true, type: "TrueColorMatte"}), class:"avatar-img rounded-circle") %> <%# end %>
<%= image_tag field.variant(attachment,resize: "400x400"), 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 %>