fix(render-image): improper srcset usage

- correct srcset image w descriptor value
- use compressed image for src fallback
This commit is contained in:
ZhenShuo Leo
2025-10-11 14:54:55 +08:00
parent 90e553541e
commit 8bfa9926c7
2 changed files with 55 additions and 19 deletions

View File

@@ -31,14 +31,18 @@
{{- else }}
<img
class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}"
srcset="
{{ (.Resize "330x").RelPermalink }} 330w,
{{ (.Resize "660x").RelPermalink }} 660w,
{{ (.Resize "1024x").RelPermalink }} 1024w,
{{ (.Resize "1320x").RelPermalink }} 2x"
src="{{ (.Resize "660x").RelPermalink }}"
data-zoom-src="{{ (.Resize "1320x").RelPermalink }}"
loading="lazy"
decoding="async"
fetchpriority="auto"
alt="{{ $altText }}"
{{ with .Width }}width="{{ . }}"{{ end }}
{{ with .Height }}height="{{ . }}"{{ end }}
src="{{ (.Resize "800x").RelPermalink }}"
srcset="
{{- (.Resize "800x").RelPermalink }} 800w,
{{- (.Resize "1280x").RelPermalink }} 1280w"
sizes="(min-width: 768px) 50vw, 65vw"
data-zoom-src="{{ .RelPermalink }}"
/>
{{- end }}
{{- else }}