diff --git a/README.md b/README.md index e642bb2..a07c549 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,10 @@ in the `index` action. Defaults to `true`. +### index_preview_only + +If true, will show only the preview in the `index` action, and not the filename or destroy link (if set). + ### index_preview_size and show_preview_size Indicate the size of the image preview for the `index` and `show` actions, respectively. diff --git a/app/views/fields/active_storage/_index.html.erb b/app/views/fields/active_storage/_index.html.erb index 4cd1612..304ad9b 100644 --- a/app/views/fields/active_storage/_index.html.erb +++ b/app/views/fields/active_storage/_index.html.erb @@ -22,7 +22,8 @@ By default, the attribute is rendered as an image tag. locals: { field: field, variant: field.index_preview_variant, - size: field.index_preview_size + size: field.index_preview_size, + preview_only: field.index_preview_only? } %> <% else %> <%= render partial: 'fields/active_storage/item', @@ -30,7 +31,8 @@ By default, the attribute is rendered as an image tag. field: field, attachment: field.data, variant: field.index_preview_variant, - size: field.index_preview_size + size: field.index_preview_size, + preview_only: field.index_preview_only? } %> <% end %> <% end %> diff --git a/app/views/fields/active_storage/_item.html.erb b/app/views/fields/active_storage/_item.html.erb index 2f1f40e..5019fc6 100644 --- a/app/views/fields/active_storage/_item.html.erb +++ b/app/views/fields/active_storage/_item.html.erb @@ -19,13 +19,17 @@ controlled via a boolean local variable. - `size`: [x, y] Maximum size of the ActiveStorage preview. +- `preview_only`: + If true, show only the previous and not the name or destroy link %> +<% preview_only = local_assigns.fetch(:preview_only, false) %> <% if field.show_display_preview? && attachment.persisted? %>