From d554b6bead78fa33c75f8ec771ab2e74494c783d Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Fri, 24 Mar 2017 16:31:50 +0200 Subject: [PATCH] layouts/_default/single.html: Only get imageConfig on local images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- layouts/_default/single.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 0b5f151..883dd9c 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -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 }}",