wide-waiter-22763
07/24/2026, 10:04 AMfield :city, as: :text, html: { show: { content: { classes: "my-test-class", style: "background: red; text: white;" } } }
This applies the class, but not the style. Looking at https://github.com/avo-hq/avo/blob/main/app/components/avo/field_wrapper_component.html.erb, I can see that style, data and classes are applied on lines 3-5 for the wrapper component, and the classes and data being applied for the content on lines 22 and 23 - but it seems like the style was simply forgotten there? 😅 (Same for the label)
Besides that, is there an easy way to make the preview image for a file field smaller? E.g. 512px squared, currently it takes up all available space 😄miniature-optician-85831
07/24/2026, 10:04 AMlemon-wall-20836
07/24/2026, 10:26 AMlemon-wall-20836
07/24/2026, 10:26 AMlemon-wall-20836
07/24/2026, 10:27 AMlemon-wall-20836
07/24/2026, 10:27 AMloud-jewelry-99127
07/24/2026, 10:33 AMlemon-wall-20836
07/24/2026, 10:33 AMlemon-wall-20836
07/24/2026, 10:33 AMloud-jewelry-99127
07/24/2026, 11:52 AMwide-waiter-22763
07/24/2026, 12:37 PM[data-field-type="file"] [data-slot="value"] img {
max-height: 400px;
object-fit: contain;
}
And I got the preview of PDFs working with:
field :pdf, as: :file, accept: "application/pdf", hide_on: :index, format_display_using: -> { record.pdf.preview(resize_to_limit: [512, 512]).processed.image }
(together with installing MuPdf so that the built-in Rails PDF Preview works). This works well now, aside from the edit page, where the preview image is not shown, but just the generic file icon. This is handled here: https://github.com/avo-hq/avo/blob/7275c9f371cbbef0722b39278c9d99d206c244af/app/components/avo/fields/common/files/view_type/grid_item_component.html.erb#L10-L17
Even though I have a preview image for that pdf, it is not shown on the edit page. I'm not really deep into the whole ActiveStorage preview stuff. No need to fix that for me, it works well enough, just wanted to share this 🙂
Thanks again for the quick answers & fixes!wide-waiter-22763
07/24/2026, 12:57 PMwide-waiter-22763
07/24/2026, 1:08 PM<% if is_audio? %>
<%= audio_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
<% elsif is_video? %>
<%= video_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
<% elsif file.previewable? %>
<%= image_tag file.preview(resize_to_limit: [700, 700]).url, class: "rounded-lg max-w-full h-auto self-start object-cover #{@extra_classes}", loading: :lazy, width: file.metadata["width"], height: file.metadata["height"] %>
<% else %>
<show generic file icon>
<% endloud-jewelry-99127
07/24/2026, 1:26 PMwide-waiter-22763
07/24/2026, 1:34 PMwide-waiter-22763
07/24/2026, 2:37 PM<% if file.representable? && is_image? %>, as otherwise regular images stopped working.
So the whole change is just the additional % elsif file.previewable? %> block (I also changed this to preview(...).processed.url)loud-jewelry-99127
07/26/2026, 7:39 AM