Sha256: e2237cdc2b168bad2131965854ac04f250ef1970cb942c819850209643adf65a

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

<%#
# 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`
- `size`:
  [x, y]
  Maximum size of the ActiveStorage preview.
%>
<% if field.show_display_preview? %>
  <div>
    <%= render partial: 'fields/active_storage/preview', locals: local_assigns %>
  </div>
<% end %>

<div>
  <%= link_to attachment.filename, field.blob_url(attachment), title: attachment.filename %>
</div>

<% if field.destroy_url.present? %>
  <% destroy_url = field.destroy_url.call(namespace, field.data.record, attachment) %>
  <div>
    <%= link_to 'Remove', destroy_url, method: :delete, class: 'remove-attachment-link' %>
  </div>
  <hr>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
administrate-field-active_storage-0.3.4 app/views/fields/active_storage/_item.html.erb
administrate-field-active_storage-0.3.3 app/views/fields/active_storage/_item.html.erb