diff --git a/app/assets/stylesheets/rich-text-content.css b/app/assets/stylesheets/rich-text-content.css
index 57686f5a0..03cda4643 100644
--- a/app/assets/stylesheets/rich-text-content.css
+++ b/app/assets/stylesheets/rich-text-content.css
@@ -110,6 +110,8 @@
}
}
+ /* Attachments */
+
figure {
display: inline-block;
position: relative;
@@ -129,6 +131,42 @@
}
}
+ .attachment {
+ border: 1px solid #cdbbfa;
+ border-radius: 16px;
+ padding: 24px;
+ background-color: white;
+ box-shadow: 0 0 0 2px #e3d8fd;
+ font-family: sans-serif;
+ display: inline-block;
+
+ &:not(:has(img,embed,video)) {
+ max-width: 25rem;
+ }
+
+ embed,video {
+ max-width: 100%;
+ }
+ }
+
+ .attachment__caption {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
+
+ .attachment__name {
+ font-size: 24px;
+ font-weight: 700;
+ color: #1f1f1f;
+ }
+
+ .attachment__size {
+ font-size: 16px;
+ font-weight: 600;
+ color: #888;
+ }
+
/* Code */
code[data-language] {
display: block;
diff --git a/app/views/active_storage/blobs/_blob.html.erb b/app/views/active_storage/blobs/_blob.html.erb
index 49ba357dd..1744b9e39 100644
--- a/app/views/active_storage/blobs/_blob.html.erb
+++ b/app/views/active_storage/blobs/_blob.html.erb
@@ -1,14 +1,34 @@
- attachment--<%= blob.filename.extension %>">
- <% if blob.representable? %>
- <%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
- <% end %>
+<% if blob.representable? %>
+
+ <%= render "active_storage/blobs/web/representation", blob: blob %>
-
- <% if caption = blob.try(:caption) %>
- <%= caption %>
- <% else %>
- <%= blob.filename %>
+
+ <% if caption = blob.try(:caption) %>
+ <%= caption %>
+ <% else %>
+ <%= blob.filename %>
+ <% end %>
<%= number_to_human_size blob.byte_size %>
- <% end %>
-
-
+ <%= link_to rails_blob_path(blob, disposition: :attachment), class: "attachment__file-link", download: blob.filename, title: "Download #{blob.filename}" do %>
+ Download
+ <% end %>
+
+
+<% else %>
+ <%= link_to rails_blob_path(blob, disposition: :attachment),
+ class: "attachment attachment--file attachment--#{blob.filename.extension}",
+ download: blob.filename,
+ title: "Download #{blob.filename}" do
+ %>
+ <%= render "active_storage/blobs/web/representation", blob: blob %>
+
+
+ <% if caption = blob.try(:caption) %>
+ <%= caption %>
+ <% else %>
+ <%= blob.filename %>
+ <% end %>
+ <%= number_to_human_size blob.byte_size %>
+
+ <% end %>
+<% end %>
diff --git a/app/views/active_storage/blobs/web/_representation.html.erb b/app/views/active_storage/blobs/web/_representation.html.erb
new file mode 100644
index 000000000..ca497fd1d
--- /dev/null
+++ b/app/views/active_storage/blobs/web/_representation.html.erb
@@ -0,0 +1,23 @@
+<% size = local_assigns[:in_gallery] ? [800, 600] : [1024, 768] %>
+
+<% if blob.video? %>
+ <%= tag.video \
+ src: rails_blob_path(blob),
+ controls: true,
+ preload: :none,
+ width: "100%", height: "100%" %>
+<% elsif blob.audio? %>
+
+<% elsif blob.content_type == "application/pdf" %>
+