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

19 lines
748 B
HTML

{{ $src := .Destination }}
{{ $alt := .Text }}
{{ $width := "" }}
{{ $height := "" }}
{{ $srcset := "" }}
{{- if not (strings.HasPrefix $src "http") -}}
{{- $img := .Page.Resources.GetMatch $src -}}
{{- if $img -}}
{{- $src = $img.RelPermalink -}}
{{- $width = printf "%d" $img.Width -}}
{{- $height = printf "%d" $img.Height -}}
{{- else -}}
{{- $src = $src | relURL -}}
{{- end -}}
{{- end -}}
<span class="sen-image-frame sen-media-host"{{ with $alt }} data-title="{{ . }}"{{ end }}>
<img src="{{ $src }}" alt="{{ $alt }}"{{ with $alt }} title="{{ . }}"{{ end }} class="lazyload lazy-loaded" loading="lazy" decoding="async"{{ with $width }} width="{{ . }}"{{ end }}{{ with $height }} height="{{ . }}"{{ end }}>
</span>