From 0b16e2485c64738425dccae4078fd1e78a6d6b74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Fri, 17 Mar 2023 11:57:27 +0100
Subject: [PATCH] fix file preview

---
 .../blocks/templates/files/_preview.html.erb          | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/app/views/admin/communication/blocks/templates/files/_preview.html.erb b/app/views/admin/communication/blocks/templates/files/_preview.html.erb
index 4d72187e5..a79859be3 100644
--- a/app/views/admin/communication/blocks/templates/files/_preview.html.erb
+++ b/app/views/admin/communication/blocks/templates/files/_preview.html.erb
@@ -25,17 +25,14 @@ end
         <% @block.template.elements.each do |element| %>
           <% next unless element.blob %>
           <li>
-          <figure>
+            <figure>
               <a href="<%= element.blob.url %>" target="_blank" title="<%= element.title %>"><%= element.title %></a>
-              <% if document.file.attached? %>
-                <% file = document.file %>
                 <figcaption>
-                  <abbr title=""><%= file.filename.extension.upcase %></abbr>
-                  - <abbr title=""><%= number_to_human_size file.byte_size %></abbr>
+                  <abbr title=""><%= element.blob.filename.extension.upcase %></abbr>
+                  - <abbr title=""><%= number_to_human_size element.blob.byte_size %></abbr>
                 </figcaption>
-              <% end %>
+              </a>
             </figure>
-            </a>
           </li>
         <% end %>
       </ul>
-- 
GitLab