Add configuration flag

pull/649/head
stereobooster 2023-09-12 21:19:27 +02:00
parent 759982fd4a
commit 86dd65776f
2 changed files with 3 additions and 1 deletions

View File

@ -12,6 +12,7 @@ autoSwitchAppearance = true
enableSearch = true enableSearch = true
enableCodeCopy = true enableCodeCopy = true
enableImageLazyLoading = true enableImageLazyLoading = true
enableWebp = true
# robots = "" # robots = ""
fingerprintAlgorithm = "sha256" fingerprintAlgorithm = "sha256"

View File

@ -2,6 +2,7 @@
{{ $altText := .Text }} {{ $altText := .Text }}
{{ $caption := .Title }} {{ $caption := .Title }}
{{ $lazyLoad := $.Page.Site.Params.enableImageLazyLoading | default true }} {{ $lazyLoad := $.Page.Site.Params.enableImageLazyLoading | default true }}
{{ $webp := $.Page.Site.Params.enableWebp | default true }}
{{ if findRE "^https?" $url.Scheme }} {{ if findRE "^https?" $url.Scheme }}
<figure> <figure>
<img <img
@ -24,7 +25,7 @@
{{ with $resource }} {{ with $resource }}
<figure> <figure>
<picture> <picture>
{{ if ne .MediaType.SubType "svg" }} {{ if (and (ne .MediaType.SubType "svg") $webp) }}
<source <source
{{ if lt .Width 660 }} {{ if lt .Width 660 }}
{{ with .Resize (printf "%dx%d webp" .Width .Height) }} {{ with .Resize (printf "%dx%d webp" .Width .Height) }}