diff --git a/README.md b/README.md index b2ca0979..fa590cbd 100644 --- a/README.md +++ b/README.md @@ -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 has optional alt, title, width, and height attributes, 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: diff --git a/layouts/shortcodes/paige/figure.html b/layouts/shortcodes/paige/figure.html index 03f7e2d1..5c0a5323 100644 --- a/layouts/shortcodes/paige/figure.html +++ b/layouts/shortcodes/paige/figure.html @@ -3,7 +3,14 @@ {{ with $link }} {{ 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 }} + {{ if $link }} {{ end }}