Hi Forum!
I have the following content in a ckeditor body-field:
<figure class="align_right"><img alt="some random alt text" src="path/to/image-file" />
<figcaption>some random caption text</figcaption>
</figure>
<p>some random text</p>
I use
$text = $sanitizer->truncate($page->body, [
'type' => 'sentence',
'maxLength' => 400,
'visible' => true
]);
$content = "<p>";
$content .= $text;
$content .= "</p>";
echo $content;
to output the body-field in my template, which results in…
<p>some random caption text some random text</p>
Is there any way to tell $sanitizer->truncate to skip/remove/ignore anything that’s inside a <figure> Tag, so that I get rid of the part "some random caption text"?