Compare commits

..

1 Commits

Author SHA1 Message Date
Wen Junhua cf09f3adf9
Merge d225da3941 into dbf421848f 2023-11-27 15:42:50 +00:00
1 changed files with 54 additions and 52 deletions

View File

@ -81,64 +81,66 @@
type="image/webp" type="image/webp"
/> />
{{ end }} {{ end }}
{{ $orientation := 1 }} {{ with $img }}
{{ with .Exif }} {{ $orientation := 1 }}
{{ $orientation = .Tags.Orientation }} {{ with .Exif }}
{{ end }} {{ $orientation = .Tags.Orientation }}
{{ if eq $orientation 1 }}
<img
src="{{ .RelPermalink }}"
width="{{ $width }}"
height="{{ $height }}"
{{ with $class }} class="{{ . }}" {{ end }}
{{ with $alt }} alt="{{ . }}" {{ end }}
{{ with $lazy }} loading="lazy" decoding="async" {{ end }}
{{ if lt .Width 660 }}
src="{{ .RelPermalink }}"
{{ else }}
srcset="
{{- (.Resize "330x").RelPermalink }} 330w,
{{- (.Resize "660x").RelPermalink }} 660w
{{ if gt .Width 1024 }}
,{{ (.Resize "1024x").RelPermalink }} 1024w
{{ else }}
,{{ .RelPermalink }} {{ .Width }}w
{{ end }}
{{ if gt .Width 1320 }}
,{{ (.Resize "1320x").RelPermalink }} 2x
{{ else }}
,{{ .RelPermalink }} {{ .Width }}w
{{ end }}"
src="{{ (.Resize "660x").RelPermalink }}"
{{ end }} {{ end }}
> {{ if eq $orientation 1 }}
{{ else if (eq $orientation 8) }} <img
<img
src="{{ (.Resize "r90").RelPermalink }}"
width="{{ $width }}"
height="{{ $height }}"
{{ with $class }} class="{{ . }}" {{ end }}
{{ with $alt }} alt="{{ . }}" {{ end }}
{{ with $lazy }} loading="lazy" decoding="async" {{ end }}
{{ if lt .Width 660 }}
src="{{ .RelPermalink }}" src="{{ .RelPermalink }}"
{{ else }} width="{{ $width }}"
srcset=" height="{{ $height }}"
{{- (.Resize "330x r90").RelPermalink }} 330w, {{ with $class }} class="{{ . }}" {{ end }}
{{- (.Resize "660x r90").RelPermalink }} 660w {{ with $alt }} alt="{{ . }}" {{ end }}
{{ if gt .Width 1024 }} {{ with $lazy }} loading="lazy" decoding="async" {{ end }}
,{{ (.Resize "1024x r90").RelPermalink }} 1024w {{ if lt .Width 660 }}
src="{{ .RelPermalink }}"
{{ else }} {{ else }}
,{{ .RelPermalink }} {{ .Width }}w srcset="
{{- (.Resize "330x").RelPermalink }} 330w,
{{- (.Resize "660x").RelPermalink }} 660w
{{ if gt .Width 1024 }}
,{{ (.Resize "1024x").RelPermalink }} 1024w
{{ else }}
,{{ .RelPermalink }} {{ .Width }}w
{{ end }}
{{ if gt .Width 1320 }}
,{{ (.Resize "1320x").RelPermalink }} 2x
{{ else }}
,{{ .RelPermalink }} {{ .Width }}w
{{ end }}"
src="{{ (.Resize "660x").RelPermalink }}"
{{ end }} {{ end }}
{{ if gt .Width 1320 }} >
,{{ (.Resize "1320x r90").RelPermalink }} 2x {{ else if (eq $orientation 8) }}
<img
src="{{ (.Resize "r90").RelPermalink }}"
width="{{ $width }}"
height="{{ $height }}"
{{ with $class }} class="{{ . }}" {{ end }}
{{ with $alt }} alt="{{ . }}" {{ end }}
{{ with $lazy }} loading="lazy" decoding="async" {{ end }}
{{ if lt .Width 660 }}
src="{{ .RelPermalink }}"
{{ else }} {{ else }}
,{{ .RelPermalink }} {{ .Width }}w srcset="
{{ end }}" {{- (.Resize "330x r90").RelPermalink }} 330w,
src="{{ (.Resize "660x r90").RelPermalink }}" {{- (.Resize "660x r90").RelPermalink }} 660w
{{ if gt .Width 1024 }}
,{{ (.Resize "1024x r90").RelPermalink }} 1024w
{{ else }}
,{{ .RelPermalink }} {{ .Width }}w
{{ end }}
{{ if gt .Width 1320 }}
,{{ (.Resize "1320x r90").RelPermalink }} 2x
{{ else }}
,{{ .RelPermalink }} {{ .Width }}w
{{ end }}"
src="{{ (.Resize "660x r90").RelPermalink }}"
{{ end }}
>
{{ end }} {{ end }}
>
{{ end }} {{ end }}
</picture> </picture>
{{ end }} {{ end }}