Skip to content

Commit

Permalink
Fix KirbyText in image KirbyTag caption #1501
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Hoffmann committed May 11, 2019
1 parent d7cd044 commit 1328a52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config/tags.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Kirby\Cms\App;
use Kirby\Cms\Html;
use Kirby\Cms\Url;

Expand Down Expand Up @@ -132,6 +131,11 @@
return $link($image);
}

// render KirbyText in caption
if ($tag->caption) {
$tag->caption = [$tag->kirby()->kirbytext($tag->caption, [], true)];
}

return Html::figure([ $link($image) ], $tag->caption, [
'class' => $tag->class
]);
Expand Down
13 changes: 13 additions & 0 deletions tests/Cms/KirbyTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ public function testImageWithoutFigure()
$this->assertEquals($expected, $kirby->kirbytext('(image: https://test.com/something.jpg)'));
}

public function testImageWithCaption()
{
$kirby = new App([
'roots' => [
'index' => '/dev/null'
]
]);

$expected = '<figure><img alt="" src="/myimage.jpg"><figcaption>This is an <em>awesome</em> image and this a <a href="">link</a></figcaption></figure>';

$this->assertEquals($expected, $kirby->kirbytext('(image: myimage.jpg caption: This is an *awesome* image and this a <a href="">link</a>)'));
}

public function testFileWithinFile()
{
$kirby = new App([
Expand Down

0 comments on commit 1328a52

Please sign in to comment.