summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel F. Dickinson <20735818+danielfdickinson@users.noreply.github.com>2021-10-22 10:29:36 -0400
committerGitHub <noreply@github.com>2021-10-22 19:59:36 +0530
commit10141e278ef0289f5c82cc70c1d276f1675c007b (patch)
treeb58f8d3eb7bae9267e84cf956ec47f59004ee639
parent38891b9062100a1f6f5d9e0474d4ca702c4a9db0 (diff)
Add webp to processable formats (#540)
* Add webp format only if using Hugo extended This keeps PaperMod from having a hard dependency on Hugo extended.
-rw-r--r--layouts/partials/cover.html5
1 files changed, 4 insertions, 1 deletions
diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html
index 6c7d1ae..8ba2cd3 100644
--- a/layouts/partials/cover.html
+++ b/layouts/partials/cover.html
@@ -9,7 +9,10 @@
{{- if $addLink }}<a href="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" target="_blank"
rel="noopener noreferrer">{{ end -}}
{{- $sizes := (slice "360" "480" "720" "1080" "1500") }}
- {{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") }}
+ {{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
+ {{- if hugo.IsExtended -}}
+ {{- $processableFormats = $processableFormats | append "webp" -}}
+ {{- end -}}
{{- $prod := (hugo.IsProduction | or (eq .Site.Params.env "production")) }}
{{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }}
<img loading="lazy" srcset="{{- range $size := $sizes -}}