Files
blog/themes/Ying/layouts/_default/_markup/render-image.html
T

17 lines
607 B
HTML
Raw Normal View History

2026-01-23 20:11:27 +08:00
{{ $src := .Destination }}
2026-05-20 14:33:05 +08:00
{{ $alt := .Text }}
{{ $width := "" }}
{{ $height := "" }}
{{ $srcset := "" }}
2026-01-23 20:11:27 +08:00
{{- if not (strings.HasPrefix $src "http") -}}
{{- $img := .Page.Resources.GetMatch $src -}}
{{- if $img -}}
{{- $src = $img.RelPermalink -}}
2026-05-20 14:33:05 +08:00
{{- $width = printf "%d" $img.Width -}}
{{- $height = printf "%d" $img.Height -}}
2026-01-23 20:11:27 +08:00
{{- else -}}
{{- $src = $src | relURL -}}
{{- end -}}
{{- end -}}
2026-05-20 14:33:05 +08:00
<img src="{{ $src }}" alt="{{ $alt }}" class="lazyload lazy-loaded" loading="lazy" decoding="async"{{ with $width }} width="{{ . }}"{{ end }}{{ with $height }} height="{{ . }}"{{ end }}>