Copy the code from figure.php and add it to site/plugins/figure.php (you have to create that file first of course :))
You can now add figures to your content like this:
(figure: myimage.jpg caption: This is a nice figure)
…or with more options…
(figure: myimage.jpg caption: This is a nice figure width: 300 height: 200)
This extends the default Kirby image tag, so you can use all the additional attributes for that. Please read more about it in the docs: http://getkirby.com/docs/formatting-text
This produces the following output
<figure>
<img src="http://yourdomain.com/content/example/myimage.jpg" width="300" alt="This is a nice figure" />
<figcaption>This is a nice figure</figcaption>
</figure>
Does line 5 need a closing bracket after true?
function __construct($text=false, $markdown=true, $smartypants=true) {
Also, is there a way to add a class to the figure element itself?
If I add
class:float-left
it gets added to the img element and if I add it straight afterfigure class:float-left:
it doesn't output.And for some reason, empty p tags get added after the img, the fig caption and the figure - but maybe this is a markdown issue because it also occurs if straight html and markdownextra is used.