1
- {{- $respSizes := slice 480 720 1080 -}}
1
+ {{- $respSizes := slice 720 1080 -}}
2
2
{{- $dataSzes := "(min-width: 768px) 1080px, 100vw" -}}
3
3
4
4
{{- $holder := "GIP" -}}
14
14
{{ with $src := .Page.Resources.GetMatch .Destination }}
15
15
{{- if $responsiveImages -}}
16
16
< picture >
17
+ {{- $imageTypes := slice $src.MediaType.SubType -}}
17
18
{{- if and hugo.IsExtended (ne $src.MediaType.Type "image/webp") -}}
18
- < source type ="image/webp " srcset ="
19
- {{- with $respSizes -}}
20
- {{- range $i, $e := . -}}
21
- {{- if $i }}, {{ end -}}{{- ($src.Resize (print . "x webp " $hint " " $filter) ).RelPermalink | absURL }} {{ . }}w
22
- {{- end -}}
23
- {{- end -}}" sizes="{{ $dataSzes }} " />
19
+ {{- $imageTypes = append $imageTypes "webp" -}}
24
20
{{- end -}}
25
- < source type ="{{ $src.MediaType.Type }} " srcset ="
21
+ {{- if gt (index $respSizes 0) $src.Width -}}
22
+ {{- $respSizes = slice $src.Width -}}
23
+ {{- end -}}
24
+ {{- range $imageType := $imageTypes -}}
25
+ < source type ="{{ $imageType }} " srcset ="
26
26
{{- with $respSizes -}}
27
27
{{- range $i, $e := . -}}
28
28
{{- if ge $src.Width . -}}
31
31
{{- end -}}
32
32
{{- end -}}, {{$src.Permalink }} {{printf "%dw" ($src.Width)}}" sizes="{{ $dataSzes }} " />
33
33
< img src ="{{ $Destination | safeURL }} " width ="{{ .Width }} " height ="{{ .Height }} " alt ="{{ $Text }} " title ="{{ $Title }} " loading ="lazy " />
34
+ {{- end -}}
34
35
</ picture >
35
36
{{- else }}
36
37
< img src ="{{ $Destination | safeURL }} " width ="{{ $src.Width }} " height ="{{ $src.Height }} " alt ="{{ $Text }} " title ="{{ $Title }} " loading ="lazy " />
37
38
{{- end }}
38
- {{ end }}
39
+ {{ end }}
0 commit comments