mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
25 lines
705 B
PHP
25 lines
705 B
PHP
|
<?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'));
|
||
|
return "<img src=\"{$src}\" alt=\"{$alt}\"/>";
|
||
|
}
|
||
|
|
||
|
return parent::convert($element);
|
||
|
}
|
||
|
}
|