Here’s how to enter an image caption once and output it twice as an alt
attribute and as an html element with line breaks.
Specify your line breaks in your img
shortcode in every post.
Then in the Shortcode template call plainify
to strip the html from the image’s alt
attribute.
And finally use safeHTML
to render the line breaks inside an element
Example Shortcode template
`< img src=“{{ $.Page.Site.BaseURL }}{{ .Get “src” }}” alt=“{{ with .Get “caption”}}{{ . | plainify }}{{ end }}”/>
{{ with .Get "caption"}}{{ . | safeHTML }}{{ end }}
`Example Shortcode usage in .md files
{{< img src="/images/mi3_800x398.jpg" caption="Untitled,<br> oil on canvas,<br> 142.5 x 70 cm, 2010" >}}
Profit!