I’m trying to create a custom kirbytag. It’s an alternative image tag, with two parameters: the image and a css class.
Here is the code of the php tag file:
kirbytext::$tags['img'] = array(
'attr' => array(
'text'
),
'html' => function($tag)
{
$url = $tag->page()->url() . '/' . $tag->attr('img');
$class = $tag->attr('class');
return "<img src='" . $url . "'" .
" class='" . $class . "'>";
}
);
And here is how I use the tag inside the text field:
(img: amora.jpg class:img-fluid)
Unfortunatly the result when rendered is this:
<img src="http://localhost/mysite/operation-mindcrime/amora.jpg class:img-fluid" class="">
As you may see, the class name is merged with the file name…