1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-11-17 09:47:05 +01:00

layouts/_default/single.html: Only get imageConfig on local images

Don't try to get image information when the image isn't local. We
generally expect that images are in the local filesystem's static
directory, but if the user has specified a remote image—ie, with
an http:// or https:// prefix—then we shouldn't try imageConfig.
This commit is contained in:
Alan Orth 2017-03-24 16:31:50 +02:00
parent 3b3598960c
commit d554b6bead
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -10,11 +10,15 @@
{{- with .Params.images -}}{{ range first 1 . }}
"image": {
"@type": "ImageObject",
"url": "{{ . | absURL }}",
{{ with (imageConfig (printf "/static/%s" .)) }}
"url": "{{ . | absURL }}"
{{- /* Don't try to get imageConfig if image param is not local */ -}}
{{- if not (or (hasPrefix . "http://") (hasPrefix . "https://")) -}}
{{- with (imageConfig (printf "/static/%s" .)) -}}
,
"height": "{{ .Height }}",
"width": "{{ .Width }}"
{{ end }}
{{ end }}
},
{{- end -}}{{ end }}
"url": "{{ printf "%s" .Permalink }}",