Sha256: d0f15a3562a42d2b45ef6fd7560d8180f2654682b6f478209a478dd92bd23a36

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 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.
%>

<%
  # By default we don't allow attachment removal
  removable = local_assigns.fetch(:removable, false)
%>

<div>
  <%= render partial: 'fields/active_storage/preview', locals: local_assigns %>
</div>

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

<% if removable %>
  <%= link_to 'Remove', field.destroy_path(field, attachment), method: :delete, class: 'remove-attachment-link' %>
  <hr>
<% end %>

Version data entries

1 entries across 1 versions & 1 rubygems

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