Defect #42084 » Move-tooltip-from-image-to-thumbnail-element.patch
| app/assets/stylesheets/application.css | ||
|---|---|---|
|
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; }
|
||
| app/helpers/application_helper.rb | ||
|---|---|---|
|
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={})
|
||
| app/views/attachments/_links.html.erb | ||
|---|---|---|
|
<% if images.any? %>
|
||
|
<div class="thumbnails">
|
||
|
<% images.each do |attachment| %>
|
||
|
<div><%= thumbnail_tag(attachment) %></div>
|
||
|
<%= thumbnail_tag(attachment) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% end %>
|
||
| app/views/issues/tabs/_history.html.erb | ||
|---|---|---|
|
<% if Setting.thumbnails_enabled? && (thumbnail_attachments = journal_thumbnail_attachments(journal)).any? %>
|
||
|
<div class="thumbnails">
|
||
|
<% thumbnail_attachments.each do |attachment| %>
|
||
|
<div><%= thumbnail_tag(attachment) %></div>
|
||
|
<%= thumbnail_tag(attachment) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% end %>
|
||
| test/helpers/application_helper_test.rb | ||
|---|---|---|
|
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
|
||