public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!$inline instanceof Image) {
throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
}
$attrs = [];
foreach ($inline->getData('attributes', []) as $key => $value) {
$attrs[$key] = $htmlRenderer->escape($value, true);
}
$forbidUnsafeLinks = $this->config->getConfig('safe') || !$this->config->getConfig('allow_unsafe_links');
if ($forbidUnsafeLinks && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl())) {
$attrs['src'] = '';
} else {
$attrs['src'] = $htmlRenderer->escape($inline->getUrl(), true);
}
$alt = $htmlRenderer->renderInlines($inline->children());
$alt = preg_replace('/\\<[^>]*alt="([^"]*)"[^>]*\\>/', '$1', $alt);
$attrs['alt'] = preg_replace('/\\<[^>]*\\>/', '', $alt);
if (isset($inline->data['title'])) {
$attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
}
return new HtmlElement('img', $attrs, '', true);
}