From: Alexander Ebert Date: Fri, 20 Nov 2020 12:38:01 +0000 (+0100) Subject: Permit images uploaded as media to be wrapped in a link X-Git-Tag: 5.3.1~14 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f08cce49a3c25fb87e55a839c3b3a229d9701cfc;p=GitHub%2FWoltLab%2FWCF.git Permit images uploaded as media to be wrapped in a link --- diff --git a/wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php b/wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php index 332c2a9adb..5c7532d81d 100644 --- a/wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php @@ -36,6 +36,16 @@ class WoltLabSuiteMediaBBCode extends AbstractBBCode { if ($parser instanceof HtmlBBCodeParser && $parser->getRemoveLinks()) { $removeLinks = true; } + else { + /** @var \DOMElement $element */ + $element = $closingTag['__parents'][0] ?? null; + if ($element && $element->nodeName === 'a') { + // We do permit media elements to be nested inside a link, but we must suppress + // the thumbnail link to be generated. Removing the link technically is meant + // to be something else, but we use it here for backward compatibility. + $removeLinks = true; + } + } /** @var ViewableMedia $media */ $media = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.media', $mediaID); diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php index 898482b39b..0d658fa90f 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php @@ -161,6 +161,10 @@ class HtmlInputNodeImg extends AbstractHtmlInputNode { $blockElements = HtmlBBCodeParser::getInstance()->getBlockBBCodes(); while ($parent = $parent->parentNode) { switch ($parent->nodeName) { + case 'a': + // Permit the media element to be placed inside a link. + break 2; + case 'blockquote': case 'body': case 'code':