Files
fizzy/app/views/active_storage/blobs/web/_representation.html.erb
T
Jorge Manrubia cf5f0a9f3f Set ratio for videos via style
And update lexical to allow style attributes
2025-06-03 11:41:10 +02:00

24 lines
953 B
Plaintext

<% size = local_assigns[:in_gallery] ? [800, 600] : [1024, 768] %>
<% width = blob.metadata["width"] %>
<% height = blob.metadata["height"] %>
<% if blob.video? %>
<%= tag.video \
src: rails_blob_path(blob),
controls: true,
preload: :none,
style: "aspect-ratio: #{width} / #{height};",
width: width,
height: height %>
<% elsif blob.audio? %>
<audio controls="true" width="100%" preload="metadata">
<source src="<%= rails_blob_url(blob) %>" type="<%= blob.content_type %>">
</audio>
<% elsif blob.variable? %>
<%= image_tag url_for(blob.variant(loader: { n: -1 }, resize_to_limit: size)), width: width, height: height %>
<% elsif blob.previewable? %>
<%= image_tag url_for(blob.preview(resize_to_limit: size)), width: width, height: height %>
<% else %>
<span class="attachment__icon"><%= blob.filename.extension&.downcase.presence || "unknown" %></span>
<% end %>