mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-12-19 00:52:19 +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:
parent
3b3598960c
commit
d554b6bead
@ -10,11 +10,15 @@
|
|||||||
{{- with .Params.images -}}{{ range first 1 . }}
|
{{- with .Params.images -}}{{ range first 1 . }}
|
||||||
"image": {
|
"image": {
|
||||||
"@type": "ImageObject",
|
"@type": "ImageObject",
|
||||||
"url": "{{ . | absURL }}",
|
"url": "{{ . | absURL }}"
|
||||||
{{ with (imageConfig (printf "/static/%s" .)) }}
|
{{- /* 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 }}",
|
"height": "{{ .Height }}",
|
||||||
"width": "{{ .Width }}"
|
"width": "{{ .Width }}"
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
},
|
},
|
||||||
{{- end -}}{{ end }}
|
{{- end -}}{{ end }}
|
||||||
"url": "{{ printf "%s" .Permalink }}",
|
"url": "{{ printf "%s" .Permalink }}",
|
||||||
|
Loading…
Reference in New Issue
Block a user