aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/active_storage/blobs/_blob.html.erb
blob: 6e4105d5cfb1e5029d177b1e8eb6b8ba147fa30b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<% transformations = { resize: local_assigns[:in_gallery] ? "800x600>" : "1024x768>" } %>
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
  <% if blob.variable? %>
    <%= image_tag blob.variant(transformations) %>
  <% elsif blob.previewable? %>
    <%= image_tag blob.preview(transformations) %>
  <% end %>

  <figcaption class="attachment__caption">
    <% if caption = blob.try(:caption) %>
      <%= caption %>
    <% else %>
      <span class="attachment__name"><%= blob.filename %></span>
      <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
    <% end %>
  </figcaption>
</figure>