fix(helper/image): add support for relative linked image
This commit is contained in:
parent
426d1f3846
commit
f0b3617ec4
@ -12,20 +12,14 @@
|
|||||||
{{ $result = merge $result (dict "permalink" $imageValue) }}
|
{{ $result = merge $result (dict "permalink" $imageValue) }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $pageResourceImage := .Context.Resources.GetMatch (printf "%s" ($imageValue | safeURL)) }}
|
{{ $pageResourceImage := .Context.Resources.GetMatch (printf "%s" ($imageValue | safeURL)) }}
|
||||||
{{ $siteResourceImage := resources.GetMatch (printf "%s" ($imageValue | safeURL)) }}
|
|
||||||
|
|
||||||
{{ if $pageResourceImage }}
|
{{ if $pageResourceImage }}
|
||||||
<!-- If image is found under page bundle -->
|
<!-- If image is found under page bundle -->
|
||||||
{{ $result = merge $result (dict "permalink" $pageResourceImage.RelPermalink) }}
|
{{ $result = merge $result (dict "permalink" $pageResourceImage.RelPermalink) }}
|
||||||
{{ $result = merge $result (dict "resource" $pageResourceImage) }}
|
{{ $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 }}
|
{{ else }}
|
||||||
<!-- Can not find the image -->
|
<!-- Can not find the image under page bundle. Could be a relative linked image -->
|
||||||
{{ errorf "Failed loading image: %q" $imageValue }}
|
{{ $result = merge $result (dict "permalink" $imageValue) }}
|
||||||
{{ $result = merge $result (dict "exists" false) }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user