<% if blob.representable? %> <% representation = blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %> <% if representation.image&.attached? || representation.key.present? %>
<%= image_tag representation %> <% else %>
<%= image_tag blob %> <% end %>
<% if caption = blob.try(:caption) %> <%= caption %> <% else %> <%= blob.filename %> <%= number_to_human_size blob.byte_size %> <% end %>
<% end %>