diff options
author | Jimmy Cai <jimmehcai@gmail.com> | 2020-09-11 00:24:19 +0300 |
---|---|---|
committer | Jimmy Cai <jimmehcai@gmail.com> | 2020-09-11 00:24:19 +0300 |
commit | 3e18e165e0dbc10ea1e81c745a04ea7ae82c6e47 (patch) | |
tree | 589418f30d4d9acd2d2131b3a91ba90264d2b5b6 | |
parent | 19ff7a46bb2043c10c519adbdad3620678120d54 (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.html | 3 |
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 }} |