From b3d68c01bb77ba1a3c9c8a5f0a4b124b858d67fe Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 4 Jul 2023 17:39:03 +0200 Subject: [PATCH] Fix the support for the alignment of embedded media --- .../html/input/node/HtmlInputNodeImg.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 71b2fd343e..0eae3a6e4b 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 @@ -158,8 +158,15 @@ class HtmlInputNodeImg extends AbstractHtmlInputNode $thumbnail = $matches['thumbnail']; } - if (\preg_match('~\bmessageFloatObject(?PLeft|Right)\b~', $class, $matches)) { - $float = ($matches['float'] === 'Left') ? 'left' : 'right'; + $replaceElement = $element; + $parent = $element->parentNode; + \assert($parent instanceof \DOMElement); + if ($parent->tagName === "figure") { + if (\preg_match('~\b(?image-style-side-left|image-style-side)\b~', $parent->getAttribute('class'), $matches)) { + $float = ($matches['float'] === 'image-style-side-left') ? 'left' : 'right'; + } + + $replaceElement = $parent; } $attributes = [ @@ -171,7 +178,7 @@ class HtmlInputNodeImg extends AbstractHtmlInputNode $newElement = $element->ownerDocument->createElement('woltlab-metacode'); $newElement->setAttribute('data-name', 'wsm'); $newElement->setAttribute('data-attributes', \base64_encode(JSON::encode($attributes))); - DOMUtil::replaceElement($element, $newElement, false); + DOMUtil::replaceElement($replaceElement, $newElement, false); // The media bbcode is a block element that may not be placed inside inline elements. $parent = $newElement; -- 2.20.1