diff --git a/app/views/trestle/active_storage/_field.html.erb b/app/views/trestle/active_storage/_field.html.erb index 6b85f40..9a8a2d5 100644 --- a/app/views/trestle/active_storage/_field.html.erb +++ b/app/views/trestle/active_storage/_field.html.erb @@ -1,12 +1,19 @@
<% if attachment.attached? %>
- <% if attachment.blob.image? %> - <%= link_to image_tag(main_app.rails_blob_url(attachment), class: 'active-storage__image'), - main_app.rails_blob_url(attachment), target: 'blank' %> + <% if attachment.previewable? %> + <%= link_to image_tag(main_app.url_for(attachment.preview(resize: "300x300>")), class: "active-storage__image"), + main_app.rails_blob_path(attachment, disposition: "attachment") %> + <% elsif attachment.variable? %> + <%= link_to image_tag(main_app.url_for(attachment.variant(resize: "300x300>")), class: "active-storage__image"), + main_app.rails_blob_path(attachment, disposition: "attachment") %> <% else %> - <%= link_to(main_app.rails_blob_url(attachment), class: 'active-storage__link') %> + <%= link_to main_app.rails_blob_path(attachment, disposition: "attachment"), class: "btn btn-info" do %> + + Download <%= field_name %> + <% end %> <% end %> +
<%= attachment.blob.filename %>
<%= builder.check_box("delete_#{field_name}", label: "Delete #{field_name}") %>