summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorIan GrĂ¼nig <ian.gruenig@gmail.com>2021-08-22 08:15:28 +0200
committerGitHub <noreply@github.com>2021-08-22 11:45:28 +0530
commitdcbe6277bbbf6780c4697b5180d2ace51ba4196d (patch)
treee8e386cba1eee0a4524dad6caf21609320c51beb /layouts
parent1214963760148f303390c568ee1f013cf64a896e (diff)
Add width and height attributes to cover images (#519)
- Ensures that the browser can allocate the correct amount of space in the document while the image is loading. - Reduces CLS #499
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/cover.html5
1 files changed, 3 insertions, 2 deletions
diff --git a/layouts/partials/cover.html b/layouts/partials/cover.html
index 3b61a05..e7e2df4 100644
--- a/layouts/partials/cover.html
+++ b/layouts/partials/cover.html
@@ -15,8 +15,9 @@
{{- if (ge $cover.Width $size) -}}
{{ printf "%s %s" (($cover.Resize (printf "%sx" $size)).Permalink) (printf "%sw ," $size) -}}
{{ end }}
- {{- end -}}{{$cover.Permalink }} {{printf "%dw" ($cover.Width)}}"
- sizes="(min-width: 768px) 720px, 100vw" src="{{ $cover.Permalink }}" alt="{{ $alt }}" />
+ {{- end -}}{{$cover.Permalink }} {{printf "%dw" ($cover.Width)}}"
+ sizes="(min-width: 768px) 720px, 100vw" src="{{ $cover.Permalink }}" alt="{{ $alt }}"
+ width="{{ $cover.Width }}" height="{{ $cover.Height }}">
{{- else }}{{/* Unprocessable image or responsive images disabled */}}
<img loading="lazy" src="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" alt="{{ $alt }}">
{{- end }}