Skip to content

Commit

Permalink
Add webp to processable formats (adityatelange#540)
Browse files Browse the repository at this point in the history
* Add webp format only if using Hugo extended

This keeps PaperMod from having a hard dependency on Hugo extended.
  • Loading branch information
danielfdickinson authored Oct 22, 2021
1 parent 38891b9 commit 10141e2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion layouts/partials/cover.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down

0 comments on commit 10141e2

Please sign in to comment.