1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-12-20 01:22:19 +01:00

layouts: Add imageConfig to set height and width

Hugo 0.18 introduced the imageConfig function which allows you to
access the height and width of images, which makes bots consuming
the structured data happy.
This commit is contained in:
Alan Orth 2017-02-21 08:24:01 +02:00
parent 4d7a544dac
commit bf9bca9656
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -10,7 +10,11 @@
{{- with .Params.images -}}{{ range first 1 . }}
"image": {
"@type": "ImageObject",
"url": "{{ . | absURL }}"
"url": "{{ . | absURL }}",
{{ with (imageConfig (printf "/static/%s" .)) }}
"height": "{{ .Height }}",
"width": "{{ .Width }}"
{{ end }}
},
{{- end -}}{{ end }}
"url": "{{ printf "%s" .Permalink }}",