Figure shortcode should use page resources

The figure shortcode requires specifying the image’s src attribute explicitly, but it would be better if it used Page.Resources to populate the URL (and perhaps other attributes).

I am using ugly URLs and page bundles. Because of this, my images end up in a subdirectory one level deeper than my post’s HTML file:

- content/
    - foobar/
        - index.md     --> becomes /foobar.html
        - image.png    --> becomes /foobar/image.png

In my Markdown, I therefore need to use ![Alt](foobar/image.png) instead of the more natural ![Alt](image.png). And these relative URLs get messed up if the post folder gets renamed, or if an excerpt of the post gets embedded somewhere else.

Instead, I had luck with modifying the figure shortcode like so:

<img src="{{ with .Get "src" | $.Page.Resources.GetMatch }}{{ .RelPermalink }}{{ end }}"  ...

Now I can just write {{< figure src="image.png" >}} and it uses Page.Resource's ability to figure out the right path for the image.

Probably with this:

 <img src="{{ with .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) }}{{ .RelPermalink }}{{ end }}"

you get even more relaxed writings (no need for extension)

{{< figure src="image" >}}