mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 10:21:46 +01:00
feat(helper/image): better detection of external image
By using strings.HasPrefix, it matches any images which name starts with http
This commit is contained in:
parent
19ff7a46bb
commit
3e18e165e0
1 changed files with 2 additions and 1 deletions
|
@ -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 }}
|
||||
|
|
Loading…
Reference in a new issue