add browser-level lazy loading

ref: https://web.dev/browser-level-image-lazy-loading/
This commit is contained in:
Aditya Telange 2021-03-16 13:18:57 +05:30
parent a982a29e24
commit c353447d8e
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77
2 changed files with 2 additions and 2 deletions

View File

@ -1,3 +1,3 @@
<p> <p>
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}" {{ end }} /> <img loading="lazy" src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}" {{ end }} />
</p> </p>

View File

@ -5,7 +5,7 @@
{{- if .Get "link" -}} {{- if .Get "link" -}}
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}> <a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- end }} {{- end }}
<img src="{{ .Get "src" }}{{- if eq (.Get "align") "center" }}#center{{- end }}" <img loading="lazy" src="{{ .Get "src" }}{{- if eq (.Get "align") "center" }}#center{{- end }}"
{{- if or (.Get "alt") (.Get "caption") }} {{- if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}" alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}} {{- end -}}