just an example, not sure about actual code

pull/723/head
stereobooster 2023-11-26 22:53:14 +01:00
parent 8c5f83e644
commit 69f0e2e345
1 changed files with 7 additions and 15 deletions

View File

@ -54,7 +54,7 @@
{{ end }} {{ end }}
{{ if $webp }} {{ if $webp }}
<source <source
{{ if lt .Width 660 }} {{ if or (lt .Width 660) $x2 }}
{{ with .Resize (printf "%dx%d webp" .Width .Height) }} {{ with .Resize (printf "%dx%d webp" .Width .Height) }}
src="{{ .RelPermalink }}" src="{{ .RelPermalink }}"
{{ end }} {{ end }}
@ -64,17 +64,12 @@
{{- (.Resize "660x webp").RelPermalink }} 660w {{- (.Resize "660x webp").RelPermalink }} 660w
{{ if gt .Width 1024 }} {{ if gt .Width 1024 }}
,{{ (.Resize "1024x webp").RelPermalink }} 1024w ,{{ (.Resize "1024x webp").RelPermalink }} 1024w
{{ else }}
{{ with .Resize (printf "%dx%d webp" .Width .Height) }}
,{{ .RelPermalink }} {{ .Width }}w
{{ end }}
{{ end }} {{ end }}
{{ if gt .Width 1320 }} {{ if gt .Width 1320 }}
,{{ (.Resize "1320x webp").RelPermalink }} 2x ,{{ (.Resize "1320x webp").RelPermalink }} 2x
{{ else }} {{ end }}
{{ with .Resize (printf "%dx%d webp" .Width .Height) }} {{ with .Resize (printf "%dx%d webp" .Width .Height) }}
,{{ .RelPermalink }} {{ .Width }}w ,{{ .RelPermalink }} {{ .Width }}w
{{ end }}
{{ end }}" {{ end }}"
src="{{ (.Resize "660x webp").RelPermalink }}" src="{{ (.Resize "660x webp").RelPermalink }}"
{{ end }} {{ end }}
@ -88,7 +83,7 @@
{{ with $class }} class="{{ . }}" {{ end }} {{ with $class }} class="{{ . }}" {{ end }}
{{ with $alt }} alt="{{ . }}" {{ end }} {{ with $alt }} alt="{{ . }}" {{ end }}
{{ with $lazy }} loading="lazy" decoding="async" {{ end }} {{ with $lazy }} loading="lazy" decoding="async" {{ end }}
{{ if lt .Width 660 }} {{ if or (lt .Width 660) $x2 }}
src="{{ .RelPermalink }}" src="{{ .RelPermalink }}"
{{ else }} {{ else }}
srcset=" srcset="
@ -96,14 +91,11 @@
{{- (.Resize "660x").RelPermalink }} 660w {{- (.Resize "660x").RelPermalink }} 660w
{{ if gt .Width 1024 }} {{ if gt .Width 1024 }}
,{{ (.Resize "1024x").RelPermalink }} 1024w ,{{ (.Resize "1024x").RelPermalink }} 1024w
{{ else }}
,{{ .RelPermalink }} {{ .Width }}w
{{ end }} {{ end }}
{{ if gt .Width 1320 }} {{ if gt .Width 1320 }}
,{{ (.Resize "1320x").RelPermalink }} 2x ,{{ (.Resize "1320x").RelPermalink }} 2x
{{ else }} {{ end }}
,{{ .RelPermalink }} {{ .Width }}w ,{{ .RelPermalink }} {{ .Width }}w"
{{ end }}"
src="{{ (.Resize "660x").RelPermalink }}" src="{{ (.Resize "660x").RelPermalink }}"
{{ end }} {{ end }}
> >