diff options
Diffstat (limited to 'layouts/partials/get_image.html')
-rw-r--r-- | layouts/partials/get_image.html | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/layouts/partials/get_image.html b/layouts/partials/get_image.html index 72c74af..31e833c 100644 --- a/layouts/partials/get_image.html +++ b/layouts/partials/get_image.html @@ -1,12 +1,15 @@ -{{ if and .keyword (.context.Resources.ByType "image") }} -{{ .context.Scratch.Set "img" ((.context.Resources.ByType "image").GetMatch .keyword).Permalink }} -{{ else if or (hasPrefix .url "http://") (hasPrefix .url "https://") }} -{{ .context.Scratch.Set "img" (.url | absURL) }} -{{ else if resources.GetMatch .url }} -{{ .context.Scratch.Set "img" (resources.GetMatch .url).Permalink }} -{{ else if .url }} -{{ .context.Scratch.Set "img" (.url | absURL) }} -{{ end }} -{{ $img := .context.Scratch.Get "img" }} -{{ .context.Scratch.Delete "img" }} -{{ return $img }}
\ No newline at end of file +{{- $img := "" }} +{{- $validKeyword := false }} +{{- if .keyword }} +{{- if (.context.Resources.ByType "image").GetMatch .keyword }} +{{- $validKeyword = true}} +{{- end }} +{{- end }} +{{- if $validKeyword }} +{{- $img = ((.context.Resources.ByType "image").GetMatch .keyword).Permalink }} +{{- else if resources.GetMatch .url }} +{{- $img = (resources.GetMatch .url).Permalink }} +{{- else if .url }} +{{- $img = (.url | absURL) }} +{{- end }} +{{- return $img }}
\ No newline at end of file |