Patch #42133 ยป Move-tooltip-from-image-to-thumbnail-element-for-r23452.patch
app/assets/stylesheets/application.css | ||
---|---|---|
1126 | 1126 |
div.attachments span.author { font-size: 0.9em; color: #888; } |
1127 | 1127 |
div.thumbnails {margin:0.6em;} |
1128 |
div.thumbnails div {background:#fff;border:2px solid #ddd;display:inline-block;margin-right:2px;}
|
|
1129 |
div.thumbnails img {margin: 3px; vertical-align: middle;}
|
|
1128 |
div.thumbnail {background:#fff;border:2px solid #ddd;display:inline-block;margin-right:2px;} |
|
1129 |
div.thumbnail img {margin: 3px; vertical-align: middle;} |
|
1130 | 1130 |
#history div.thumbnails {margin-left: 2em;} |
1131 | 1131 |
p.other-formats { text-align: right; font-size:0.9em; color: #666; } |
app/helpers/application_helper.rb | ||
---|---|---|
346 | 346 |
def thumbnail_tag(attachment) |
347 | 347 |
thumbnail_size = Setting.thumbnails_size.to_i |
348 | 348 |
thumbnail_path = thumbnail_path(attachment, :size => thumbnail_size * 2) |
349 |
link_to( |
|
350 |
image_tag( |
|
351 |
thumbnail_path, |
|
352 |
:srcset => "#{thumbnail_path} 2x", |
|
353 |
:style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;", |
|
354 |
:title => attachment.filename, |
|
355 |
:alt => attachment.filename, |
|
356 |
:loading => "lazy" |
|
357 |
), |
|
358 |
attachment_path( |
|
359 |
attachment |
|
349 |
tag.div class: 'thumbnail', title: attachment.filename do |
|
350 |
link_to( |
|
351 |
image_tag( |
|
352 |
thumbnail_path, |
|
353 |
:srcset => "#{thumbnail_path} 2x", |
|
354 |
:style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;", |
|
355 |
:alt => attachment.filename, |
|
356 |
:loading => "lazy" |
|
357 |
), |
|
358 |
attachment_path(attachment) |
|
360 | 359 |
) |
361 |
)
|
|
360 |
end
|
|
362 | 361 |
end |
363 | 362 |
def toggle_link(name, id, options={}) |
app/views/attachments/_links.html.erb | ||
---|---|---|
42 | 42 |
<% if images.any? %> |
43 | 43 |
<div class="thumbnails"> |
44 | 44 |
<% images.each do |attachment| %> |
45 |
<div><%= thumbnail_tag(attachment) %></div>
|
|
45 |
<%= thumbnail_tag(attachment) %>
|
|
46 | 46 |
<% end %> |
47 | 47 |
</div> |
48 | 48 |
<% end %> |
app/views/issues/tabs/_history.html.erb | ||
---|---|---|
27 | 27 |
<% if Setting.thumbnails_enabled? && (thumbnail_attachments = journal_thumbnail_attachments(journal)).any? %> |
28 | 28 |
<div class="thumbnails"> |
29 | 29 |
<% thumbnail_attachments.each do |attachment| %> |
30 |
<div><%= thumbnail_tag(attachment) %></div>
|
|
30 |
<%= thumbnail_tag(attachment) %>
|
|
31 | 31 |
<% end %> |
32 | 32 |
</div> |
33 | 33 |
<% end %> |
test/helpers/application_helper_test.rb | ||
---|---|---|
1918 | 1918 |
end |
1919 | 1919 |
def test_thumbnail_tag |
1920 |
a = Attachment.find(3) |
|
1921 |
assert_select_in( |
|
1922 |
thumbnail_tag(a), |
|
1923 |
'a[href=?] img[title=?][alt=?][src=?][loading="lazy"]', |
|
1924 |
"/attachments/3", "logo.gif", "logo.gif", "/attachments/thumbnail/3/200") |
|
1920 |
attachment = Attachment.find(3) |
|
1921 |
assert_select_in thumbnail_tag(attachment), 'div.thumbnail[title=?]', 'logo.gif' do |
|
1922 |
assert_select 'a[href=?]', '/attachments/3' do |
|
1923 |
assert_select 'img[alt=?][src=?][loading="lazy"]', "logo.gif", "/attachments/thumbnail/3/200" |
|
1924 |
end |
|
1925 |
end |
|
1925 | 1926 |
end |
1926 | 1927 |
def test_link_to_project |