From 759982fd4ac39c16319fc976d2df10fe1e0d6ab5 Mon Sep 17 00:00:00 2001 From: stereobooster Date: Mon, 11 Sep 2023 15:11:55 +0200 Subject: [PATCH 1/2] Picture + webp --- exampleSite/content/samples/markdown/index.md | 4 ++ layouts/_default/_markup/render-image.html | 60 ++++++++++++------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/exampleSite/content/samples/markdown/index.md b/exampleSite/content/samples/markdown/index.md index 601fae2a..d9f91110 100755 --- a/exampleSite/content/samples/markdown/index.md +++ b/exampleSite/content/samples/markdown/index.md @@ -9,6 +9,10 @@ This article offers a sample of basic Markdown formatting that can be used in Co +## Image + +![sample image](thumb-surendran-mp-IhWYiwSxm8g-unsplash.jpg) + ## Headings The following HTML `

`—`

` elements represent six levels of section headings. `

` is the highest section level while `

` is the lowest. diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index c1fe3634..699b3f25 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -23,29 +23,49 @@ {{ end }} {{ with $resource }}
- + {{ if ne .MediaType.SubType "svg" }} + + {{ end }} + {{ $altText }} + alt="{{ $altText }}" + {{ if $lazyLoad }} + loading="lazy" + {{ end }} + /> + {{ with $caption }}
{{ . | markdownify }}
{{ end }}
{{ else }} From 86dd65776f24c5c5a1296ce91dd1975b77a73275 Mon Sep 17 00:00:00 2001 From: stereobooster Date: Tue, 12 Sep 2023 21:19:27 +0200 Subject: [PATCH 2/2] Add configuration flag --- exampleSite/config/_default/params.toml | 1 + layouts/_default/_markup/render-image.html | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index d828f120..10baff41 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -12,6 +12,7 @@ autoSwitchAppearance = true enableSearch = true enableCodeCopy = true enableImageLazyLoading = true +enableWebp = true # robots = "" fingerprintAlgorithm = "sha256" diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 699b3f25..cbd84eba 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -2,6 +2,7 @@ {{ $altText := .Text }} {{ $caption := .Title }} {{ $lazyLoad := $.Page.Site.Params.enableImageLazyLoading | default true }} +{{ $webp := $.Page.Site.Params.enableWebp | default true }} {{ if findRE "^https?" $url.Scheme }}
- {{ if ne .MediaType.SubType "svg" }} + {{ if (and (ne .MediaType.SubType "svg") $webp) }}