In my theme I’m using Hugo 0.19’s imageConfig
function to embed image height and width in each post’s JSON LD metadata, but this fails when the user specifies a non-local image in their post’s front matter, ie an absolute URL with protocol and everything. How can I limit this so it only calls imageConfig
on local files?
Here is how I’m getting the image information, using a technique that I saw somewhere here on the forum:
"image": {
"@type": "ImageObject",
"url": "{{ . | absURL }}",
{{ with (imageConfig (printf "/static/%s" .)) }}
"height": "{{ .Height }}",
"width": "{{ .Width }}"
{{ end }}