Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Cai <jimmehcai@gmail.com>2020-09-11 00:24:19 +0300
committerJimmy Cai <jimmehcai@gmail.com>2020-09-11 00:24:19 +0300
commit3e18e165e0dbc10ea1e81c745a04ea7ae82c6e47 (patch)
tree589418f30d4d9acd2d2131b3a91ba90264d2b5b6
parent19ff7a46bb2043c10c519adbdad3620678120d54 (diff)
feat(helper/image): better detection of external image
By using strings.HasPrefix, it matches any images which name starts with http
-rw-r--r--layouts/partials/helper/image.html3
1 files changed, 2 insertions, 1 deletions
diff --git a/layouts/partials/helper/image.html b/layouts/partials/helper/image.html
index 4136e67..c8371b4 100644
--- a/layouts/partials/helper/image.html
+++ b/layouts/partials/helper/image.html
@@ -4,7 +4,8 @@
<!-- If page has `image` field set -->
{{ $result = merge $result (dict "exists" true) }}
- {{ if strings.HasPrefix $imageField "http" }}
+ {{ $url := urls.Parse $imageField }}
+ {{ if or (eq $url.Scheme "http") (eq $url.Scheme "https") }}
<!-- Is a external image -->
{{ $result = merge $result (dict "src" $imageField) }}
{{ else }}