Compare commits

...

3 Commits

Author SHA1 Message Date
Wen Junhua 6c41d70e80
Merge 1b7361c50d into 0c5d6d1125 2023-12-11 07:11:52 -07:00
Wen Junhua 1b7361c50d fix: remove redundant tags 2023-11-28 21:16:27 +08:00
Wen Junhua d225da3941 fix: add image fix 2023-11-27 23:42:08 +08:00
1 changed files with 56 additions and 23 deletions

View File

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