Skip to content

Commit 10141e2

Browse files
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.
1 parent 38891b9 commit 10141e2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

layouts/partials/cover.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
{{- if $addLink }}<a href="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" target="_blank"
1010
rel="noopener noreferrer">{{ end -}}
1111
{{- $sizes := (slice "360" "480" "720" "1080" "1500") }}
12-
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") }}
12+
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
13+
{{- if hugo.IsExtended -}}
14+
{{- $processableFormats = $processableFormats | append "webp" -}}
15+
{{- end -}}
1316
{{- $prod := (hugo.IsProduction | or (eq .Site.Params.env "production")) }}
1417
{{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }}
1518
<img loading="lazy" srcset="{{- range $size := $sizes -}}

0 commit comments

Comments
 (0)