No kirbytext function for img-captions? Italic and Bold doesn't work

I changed the regular Kirby-tag for images and added, among other things the following:

$image = $tag->file($filename);
$caption = $image->caption();
'<span class="img-caption">' . kirbytext($caption) . '</span>'

This gets the caption properly and wrapped in a paragraph-tag, but setting parts in the caption to Italic or Bold with “*” or “**” doesn’t do anything to the text. It is also not wrapped in em- or strong-tags. Is there a way to solve this?

Just an idea, not tested:

$caption = $image->caption()->markdown();

the ->markdown() does the trick, thanks!

i’m having the same issue. Which file are editing? I think this would be a nice addition to the default behavior of figcaptions.

You best bet is to copy the image tag from /kirby/extensions/tags.php into a new file, and save it in /site/tags.

Thank you! I don’t know what else to write to reach 20 char. :slight_smile:

I have the same need, so I copied the default image kirbytag from the /kirby/extensions/tags.php into a new file. Then I’ve tried to add the markdown() function but without success.

My new image.php is here

I tried, line 26:

$caption = $tag->attr('caption')->markdown();

and line 93:

    $figure->append('<figcaption>' . markdown($caption) . '</figcaption>');

But without any success :frowning:

Hm, in the file you posted, the lines are still unchanged. Please also make sure that the plugin actually gets loaded. You can verify this by returning something else from the Kirbytag like this:

kirbytext::$tags['image'] = array(
  'attr' => array(
  'html' => function($tag) {
    return 'just a test';