mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 10:21:46 +01:00
fix(helper/image): add support for relative linked image
This commit is contained in:
parent
426d1f3846
commit
f0b3617ec4
1 changed files with 2 additions and 8 deletions
|
@ -12,20 +12,14 @@
|
|||
{{ $result = merge $result (dict "permalink" $imageValue) }}
|
||||
{{ else }}
|
||||
{{ $pageResourceImage := .Context.Resources.GetMatch (printf "%s" ($imageValue | safeURL)) }}
|
||||
{{ $siteResourceImage := resources.GetMatch (printf "%s" ($imageValue | safeURL)) }}
|
||||
|
||||
{{ if $pageResourceImage }}
|
||||
<!-- If image is found under page bundle -->
|
||||
{{ $result = merge $result (dict "permalink" $pageResourceImage.RelPermalink) }}
|
||||
{{ $result = merge $result (dict "resource" $pageResourceImage) }}
|
||||
{{ else if $siteResourceImage }}
|
||||
<!-- Try search image under site's assets folder -->
|
||||
{{ $result = merge $result (dict "permalink" $siteResourceImage.RelPermalink) }}
|
||||
{{ $result = merge $result (dict "resource" $siteResourceImage) }}
|
||||
{{ else }}
|
||||
<!-- Can not find the image -->
|
||||
{{ errorf "Failed loading image: %q" $imageValue }}
|
||||
{{ $result = merge $result (dict "exists" false) }}
|
||||
<!-- Can not find the image under page bundle. Could be a relative linked image -->
|
||||
{{ $result = merge $result (dict "permalink" $imageValue) }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in a new issue