1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 09:38:27 -04:00

lazy load images within page content

This commit is contained in:
Jake Jarvis 2020-08-31 10:53:47 -04:00
parent 7f4ee60797
commit cdf867920e
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39

View File

@ -4,7 +4,7 @@
<figure>
{{ with $.Get "link" }}<a class="no-underline" href="{{ . }}"{{ if strings.HasPrefix . "http" }} target="_blank" rel="noopener"{{ end }}>{{ end }}
<picture>
<img src="{{ $optimized.Permalink }}" width="{{ $optimized.Width }}" height="{{ $optimized.Height }}"
<img src="{{ $optimized.Permalink }}" loading="lazy" width="{{ $optimized.Width }}" height="{{ $optimized.Height }}"
alt="{{ . | $.Page.RenderString | plainify | safeHTML }}" title="{{ . | $.Page.RenderString | plainify | safeHTML }}">
</picture>
{{ if $.Get "link" }}</a>{{ end }}
@ -14,7 +14,7 @@
{{- else }}
<p class="image">
{{ with .Get "link" }}<a class="no-underline" href="{{ . }}"{{ if strings.HasPrefix . "http" }} target="_blank" rel="noopener"{{ end }}>{{ end }}
<img src="{{ $optimized.Permalink }}" width="{{ $optimized.Width }}" height="{{ $optimized.Height }}"
<img src="{{ $optimized.Permalink }}" loading="lazy" width="{{ $optimized.Width }}" height="{{ $optimized.Height }}"
{{- with .Get "alt" }} alt="{{ . | safeHTML }}" title="{{ . | safeHTML }}"{{ end }}>
{{ if .Get "link" }}</a>{{ end }}
</p>