2022-04-29 07:17:14 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Entities\Tools\Markdown;
|
|
|
|
|
|
|
|
use League\HTMLToMarkdown\Converter\ImageConverter;
|
|
|
|
use League\HTMLToMarkdown\ElementInterface;
|
|
|
|
|
|
|
|
class CustomImageConverter extends ImageConverter
|
|
|
|
{
|
|
|
|
public function convert(ElementInterface $element): string
|
|
|
|
{
|
|
|
|
$parent = $element->getParent();
|
|
|
|
|
|
|
|
// Remain as HTML if within diagram block.
|
|
|
|
$withinDrawing = $parent && !empty($parent->getAttribute('drawio-diagram'));
|
|
|
|
if ($withinDrawing) {
|
|
|
|
$src = e($element->getAttribute('src'));
|
|
|
|
$alt = e($element->getAttribute('alt'));
|
2022-04-29 10:38:06 -04:00
|
|
|
|
2022-04-29 07:17:14 -04:00
|
|
|
return "<img src=\"{$src}\" alt=\"{$alt}\"/>";
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::convert($element);
|
|
|
|
}
|
|
|
|
}
|