BathHacked/energy-sparks

View on GitHub
app/views/active_storage/blobs/_blob.html.erb

Summary

Maintainability
Test Coverage
<% if blob.representable? %>
  <figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
    <%= image_tag blob.representation(resize_to_fit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
    <figcaption class="attachment__caption">
      <% if caption = blob.try(:caption) %>
        <%= caption %>
      <% end %>
    </figcaption>
  </figure>
<% else %>
  <%= link_to rails_blob_path(blob, disposition: 'preview'), class: 'btn' do %>
    <%=  file_type_icon(blob.content_type) %>
    <%=  blob.filename %>
  <% end %>
<% end %>