Change figure shortcode to use relative paths as page resources
This commit is contained in:
@@ -455,6 +455,7 @@ The `paige/figure` shortcode provides a figure with a centered image and an opti
|
|||||||
The image and caption can optionally be displayed inline instead of centered.
|
The image and caption can optionally be displayed inline instead of centered.
|
||||||
The image has optional alt, title, width, and height attributes,
|
The image has optional alt, title, width, and height attributes,
|
||||||
and can optionally be wrapped in an anchor. Only the image source parameter is required.
|
and can optionally be wrapped in an anchor. Only the image source parameter is required.
|
||||||
|
If the image source is a relative path, it is assumed to be a page resource.
|
||||||
|
|
||||||
These are the named parameters with positions, listed in the order of their positions:
|
These are the named parameters with positions, listed in the order of their positions:
|
||||||
|
|
||||||
|
@@ -3,7 +3,14 @@
|
|||||||
{{ with $link }}
|
{{ with $link }}
|
||||||
<a href="{{ . }}">
|
<a href="{{ . }}">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<img{{ with (.Get 4 | default (.Get `alt`)) }} alt="{{ . }}"{{ end }} class="figure-img img-fluid"{{ with .Get `height` }} height="{{ . }}"{{ end }} src="{{ .Get 0 | default (.Get `src`) }}"{{ with (.Get 3 | default (.Get `title`)) }} title="{{ . }}"{{ end }}{{ with .Get `width` }} width="{{ . }}"{{ end }}>
|
{{ $src := .Get 0 | default (.Get `src`) }}
|
||||||
|
{{ $url := urls.Parse $src }}
|
||||||
|
{{ if and (not $url.IsAbs) (not (hasPrefix $url.Path "/")) }}
|
||||||
|
{{ with .Page.Resources.GetMatch $src }}
|
||||||
|
{{ $src = .RelPermalink }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
<img{{ with (.Get 4 | default (.Get `alt`)) }} alt="{{ . }}"{{ end }} class="figure-img img-fluid"{{ with .Get `height` }} height="{{ . }}"{{ end }} src="{{ $src }}"{{ with (.Get 3 | default (.Get `title`)) }} title="{{ . }}"{{ end }}{{ with .Get `width` }} width="{{ . }}"{{ end }}>
|
||||||
{{ if $link }}
|
{{ if $link }}
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Reference in New Issue
Block a user