Sha256: e82a936e30fa95c4f96577d65e9770182d9bcc59ffe7c77a9170d3d280641b78

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 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`
%>

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

<% if attachment.image? and !field.url_only? %>
  <%= image_tag(field.url(attachment)) %>
<% elsif attachment.video? and attachment.previewable? and !field.url_only? %> <%# if ffmpeg is installed %>
  <%= video_tag(field.url(attachment), poster: field.preview(attachment, resize: "1920x1080>"), 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) %>
<% elsif attachment.previewable? and !field.url_only? %>
  <%= image_tag(field.preview(attachment, resize: "595x842>")) %>
  <br/>
  Download: <%= link_to(attachment.filename, field.blob_url(attachment)) %>
<% else %>
  <%= link_to(attachment.filename, field.blob_url(attachment)) %>
<% end %>

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

Version data entries

7 entries across 5 versions & 2 rubygems

Version Path
worker-field-active_storage-0.2.0 app/views/fields/active_storage/_item.html.erb
worker-field-active_storage-0.2.0 app/views/fields/active_storage/_item_index.html.erb
worker-field-active_storage-0.1.0 app/views/fields/active_storage/_item.html.erb
worker-field-active_storage-0.1.0 app/views/fields/active_storage/_item_index.html.erb
administrate-field-active_storage-0.1.6 app/views/fields/active_storage/_item.html.erb
administrate-field-active_storage-0.1.5 app/views/fields/active_storage/_item.html.erb
administrate-field-active_storage-0.1.4 app/views/fields/active_storage/_item.html.erb