From b645942dd218491bfa24b0a68971d7bf37feb771 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Thu, 9 May 2019 16:37:06 -0400 Subject: [PATCH] Add loading='lazy' attribute to some images (#2776) --- app/assets/javascripts/utilities/buildArticleHTML.js.erb | 4 ++-- app/labor/markdown_parser.rb | 2 +- .../_article_followable_area.html.erb | 1 + app/views/articles/_bottom_content.html.erb | 1 + app/views/articles/_sidebar.html.erb | 4 ++-- app/views/articles/_sticky_nav.html.erb | 6 +++--- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/utilities/buildArticleHTML.js.erb b/app/assets/javascripts/utilities/buildArticleHTML.js.erb index 8914444c6..75ab8ca94 100644 --- a/app/assets/javascripts/utilities/buildArticleHTML.js.erb +++ b/app/assets/javascripts/utilities/buildArticleHTML.js.erb @@ -49,7 +49,7 @@ function buildArticleHTML(article) { var profileUsername = article.user.username var orgHeadline = ""; if (article.organization && !document.getElementById("organization-article-index")) { - orgHeadline = '
'+article.organization.name+' logo'+article.organization.name+'
' + orgHeadline = '
'+article.organization.name+' logo'+article.organization.name+'
' } var bodyTextSnippet = ""; var commentsBlobSnippet = ""; @@ -115,7 +115,7 @@ function buildArticleHTML(article) { '+orgHeadline+'\
\ \ - '+profileUsername+' profile\ + '+profileUsername+' profile\ \
\ \ diff --git a/app/labor/markdown_parser.rb b/app/labor/markdown_parser.rb index d47c46f8e..8b678f992 100644 --- a/app/labor/markdown_parser.rb +++ b/app/labor/markdown_parser.rb @@ -90,7 +90,7 @@ class MarkdownParser next unless src # allow image to render as-is next if allowed_image_host?(src) - + img["loading"] = "lazy" img["src"] = if giphy_img?(src) src.gsub("https://media.", "https://i.") else diff --git a/app/views/additional_content_boxes/_article_followable_area.html.erb b/app/views/additional_content_boxes/_article_followable_area.html.erb index 258fb1895..8bc8fdff9 100644 --- a/app/views/additional_content_boxes/_article_followable_area.html.erb +++ b/app/views/additional_content_boxes/_article_followable_area.html.erb @@ -22,6 +22,7 @@ <%= followable.name %> profile image__PROFILE" style="border: 4px solid <%= followable.bg_color_hex %>" /> diff --git a/app/views/articles/_bottom_content.html.erb b/app/views/articles/_bottom_content.html.erb index 593917215..5358fa1eb 100644 --- a/app/views/articles/_bottom_content.html.erb +++ b/app/views/articles/_bottom_content.html.erb @@ -11,6 +11,7 @@ quality: "auto", flags: "progressive", fetch_format: "auto", + loading: "lazy", sign_url: true, alt: "#{article.user.username} profile image") %> diff --git a/app/views/articles/_sidebar.html.erb b/app/views/articles/_sidebar.html.erb index 6ecca58c6..655f7097c 100644 --- a/app/views/articles/_sidebar.html.erb +++ b/app/views/articles/_sidebar.html.erb @@ -16,8 +16,8 @@ <% @sponsors.each do |organization| %>