diff --git a/config/_default/params.toml b/config/_default/params.toml index 61e2b936..c79ad081 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -11,6 +11,7 @@ autoSwitchAppearance = true enableSearch = false enableCodeCopy = false +enableImageLazyLoading = true # robots = "" fingerprintAlgorithm = "sha256" diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 83ecf482..c2b220ad 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -3,7 +3,14 @@ {{ $caption := .Title }} {{ if findRE "^https?" $url.Scheme }}
- {{ $altText }} + {{ $altText }} {{ with $caption }}
{{ . | markdownify }}
{{ end }}
{{ else }} @@ -32,13 +39,22 @@ {{ end }} {{ end }} alt="{{ $altText }}" - loading="lazy" + {{ if .Site.Params.enableImageLazyLoading | default true }} + loading="lazy" + {{ end }} /> {{ with $caption }}
{{ . | markdownify }}
{{ end }} {{ else }}
- {{ $altText }} + {{ $altText }} {{ with $caption }}
{{ . | markdownify }}
{{ end }}
{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 06ee2dfd..9f3c52cd 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -31,7 +31,9 @@ {{ end }} {{ end }} alt="{{ $.Params.featureAlt | default $.Params.coverAlt | default "" }}" - loading="lazy" + {{ if .Site.Params.enableImageLazyLoading | default true }} + loading="lazy" + {{ end }} /> {{ with $.Params.coverCaption }}
{{ . | markdownify }}
diff --git a/layouts/partials/article-link.html b/layouts/partials/article-link.html index 93c24b18..f934bae0 100644 --- a/layouts/partials/article-link.html +++ b/layouts/partials/article-link.html @@ -23,7 +23,9 @@ 160w, {{- (.Fill "320x240 smart").RelPermalink }} 2x" src="{{ (.Fill "160x120 smart").RelPermalink }}" {{ end }} - loading="lazy" + {{ if .Site.Params.enableImageLazyLoading | default true }} + loading="lazy" + {{ end }} /> diff --git a/layouts/partials/author.html b/layouts/partials/author.html index 5aae1f8d..ca7b17bc 100644 --- a/layouts/partials/author.html +++ b/layouts/partials/author.html @@ -10,7 +10,9 @@ height="96" alt="{{ $.Site.Author.name | default "Author" }}" src="{{ $authorImage.RelPermalink }}" - loading="lazy" + {{ if .Site.Params.enableImageLazyLoading | default true }} + loading="lazy" + {{ end }} /> {{ end }} {{ end }} diff --git a/layouts/partials/home/profile.html b/layouts/partials/home/profile.html index ca465a23..324e31f1 100644 --- a/layouts/partials/home/profile.html +++ b/layouts/partials/home/profile.html @@ -14,7 +14,9 @@ height="144" alt="{{ $.Site.Author.name | default "Author" }}" src="{{ $authorImage.RelPermalink }}" - loading="lazy" + {{ if .Site.Params.enableImageLazyLoading | default true }} + loading="lazy" + {{ end }} /> {{ end }} {{ end }} diff --git a/layouts/partials/logo.html b/layouts/partials/logo.html index 4c669a57..1fefceb7 100644 --- a/layouts/partials/logo.html +++ b/layouts/partials/logo.html @@ -9,7 +9,9 @@ height="{{ div $logo.Height 2 }}" class="max-h-[10rem] max-w-[10rem] object-scale-down object-left{{ if $logo_dark }} hidden dark:flex{{ end }}" alt="{{ .Site.Title }}" - loading="lazy" + {{ if .Site.Params.enableImageLazyLoading | default true }} + loading="lazy" + {{ end }} /> {{- if $logo_dark }} {{ .Site.Title }} {{- end}} diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index 60a9edf8..b6d14289 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -11,7 +11,9 @@