diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a798261bcb..63f80f36aa 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -320,7 +320,8 @@ module ApplicationHelper
image_tag(
thumbnail_path(attachment),
:srcset => "#{thumbnail_path(attachment, :size => thumbnail_size * 2)} 2x",
- :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;"
+ :style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;",
+ :loading => "lazy"
),
attachment_path(
attachment
@@ -946,7 +947,7 @@ module ApplicationHelper
if !desc.blank? && alttext.blank?
alt = " title=\"#{desc}\" alt=\"#{desc}\""
end
- "src=\"#{image_url}\"#{alt}"
+ "src=\"#{image_url}\"#{alt} loading=\"lazy\""
else
m
end
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index 6e79dce2e9..f67a615e5f 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -171,14 +171,14 @@ class ApplicationHelperTest < Redmine::HelperTest
def test_attached_images
to_test = {
'Inline image: !logo.gif!' =>
- 'Inline image: ',
+ 'Inline image:
',
'Inline image: !logo.GIF!' =>
- 'Inline image:
',
+ 'Inline image:
',
'No match: !ogo.gif!' => 'No match:
',
'No match: !ogo.GIF!' => 'No match:
',
# link image
'!logo.gif!:http://foo.bar/' =>
- '
',
+ '
',
}
attachments = Attachment.all
to_test.each {|text, result| assert_equal "
#{result}
", textilizable(text, :attachments => attachments)} @@ -196,8 +196,8 @@ class ApplicationHelperTest < Redmine::HelperTest !attached_on_journal.png!' RAW - assert textilizable(raw, :object => journal).include?("#{result}
", textilizable(text, :attachments => attachments)} @@ -1794,7 +1794,7 @@ class ApplicationHelperTest < Redmine::HelperTest a = Attachment.find(3) assert_select_in( thumbnail_tag(a), - 'a[href=?][title=?] img[src=?]', + 'a[href=?][title=?] img[src=?][loading="lazy"]', "/attachments/3", "logo.gif", "/attachments/thumbnail/3") end diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb index fecafd660b..80df0572b2 100644 --- a/test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb @@ -49,7 +49,7 @@ class Redmine::WikiFormatting::CommonMark::ApplicationHelperTest < Redmine::Help with_settings :text_formatting => 'common_mark' do to_test.each do |filename, result| attachment = Attachment.generate!(:filename => filename) - assert_include %(