diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index e67a6e3b2..0081293b3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1126,8 +1126,8 @@ div.attachments img { vertical-align: middle; } div.attachments span.author { font-size: 0.9em; color: #888; } div.thumbnails {margin:0.6em;} -div.thumbnails div {background:#fff;border:2px solid #ddd;display:inline-block;margin-right:2px;} -div.thumbnails img {margin: 3px; vertical-align: middle;} +div.thumbnail {background:#fff;border:2px solid #ddd;display:inline-block;margin-right:2px;} +div.thumbnail img {margin: 3px; vertical-align: middle;} #history div.thumbnails {margin-left: 2em;} p.other-formats { text-align: right; font-size:0.9em; color: #666; } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3174261a9..50519c890 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -346,18 +346,18 @@ module ApplicationHelper def thumbnail_tag(attachment) thumbnail_size = Setting.thumbnails_size.to_i thumbnail_path = thumbnail_path(attachment, :size => thumbnail_size * 2) - link_to( - image_tag( - thumbnail_path, - :srcset => "#{thumbnail_path} 2x", - :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;", - :title => attachment.filename, - :loading => "lazy" - ), - attachment_path( - attachment + tag.div class: 'thumbnail', title: attachment.filename do + link_to( + image_tag( + thumbnail_path, + :srcset => "#{thumbnail_path} 2x", + :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;", + :alt => attachment.filename, + :loading => "lazy" + ), + attachment_path(attachment) ) - ) + end end def toggle_link(name, id, options={}) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index f098c1038..93cbddaea 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -42,7 +42,7 @@ <% if images.any? %>
<% images.each do |attachment| %> -
<%= thumbnail_tag(attachment) %>
+ <%= thumbnail_tag(attachment) %> <% end %>
<% end %> diff --git a/app/views/issues/tabs/_history.html.erb b/app/views/issues/tabs/_history.html.erb index 8c6f6d31b..aa5795400 100644 --- a/app/views/issues/tabs/_history.html.erb +++ b/app/views/issues/tabs/_history.html.erb @@ -27,7 +27,7 @@ <% if Setting.thumbnails_enabled? && (thumbnail_attachments = journal_thumbnail_attachments(journal)).any? %>
<% thumbnail_attachments.each do |attachment| %> -
<%= thumbnail_tag(attachment) %>
+ <%= thumbnail_tag(attachment) %> <% end %>
<% end %> diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 31c87daea..573eda42b 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -1918,11 +1918,12 @@ class ApplicationHelperTest < Redmine::HelperTest end def test_thumbnail_tag - a = Attachment.find(3) - assert_select_in( - thumbnail_tag(a), - 'a[href=?] img[title=?][src=?][loading="lazy"]', - "/attachments/3", "logo.gif", "/attachments/thumbnail/3/200") + attachment = Attachment.find(3) + assert_select_in thumbnail_tag(attachment), 'div.thumbnail[title=?]', 'logo.gif' do + assert_select 'a[href=?]', '/attachments/3' do + assert_select 'img[alt=?][src=?][loading="lazy"]', "logo.gif", "/attachments/thumbnail/3/200" + end + end end def test_link_to_project