The problem here is that several users edit the content and not everyone links the images properly.
The markdown shows  and the link breaks because config.toml has uglyurls = false.
To avoid messing too much with the build script I have, I wanted to check if the markdown matches the condition file.ext and if so, change it to ../file.ext.
Looking at the docs, there is an in function, but that doesn’t seem to be what I am looking for.
I also tried with absURL and relURL.
Looking at this again, I didn’t even need to find the ext because the context is already the render-image.html hook.
The current solution is this, but still needs work:
{{ if eq (len (findRE ".*/.*" .Destination) ) 0 }}
<img src="{{ (printf "../%s" .Destination) | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
{{ else }}
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
{{ end }}
The problem here is that I am trying to fix the url for the user, because in this particular context I can’t force the user to follow a convention.
I was thinking that another approach would be to pick up the markdown image code and add it as a resource. The render-image hook would then just find it by src and output the permalink.