Read image width only from `img` element
authorCyperghost <olaf_schmitz_1@t-online.de>
Wed, 10 Jan 2024 10:16:43 +0000 (11:16 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Wed, 10 Jan 2024 10:16:43 +0000 (11:16 +0100)
See https://github.com/WoltLab/editor/commit/deff5ef1cbac24c80a6d1d7fc230b2815391be47

wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php

index 29b72642cf1c626d078cb6fc3f982adaedd7bd02..a277060329dd55bfad6d31c1c6addbc38ae9c634 100644 (file)
@@ -126,7 +126,7 @@ class HtmlInputNodeImg extends AbstractHtmlInputNode
             }
         }
 
-        $width = $replaceElement->getAttribute("data-width");
+        $width = $element->getAttribute("data-width");
         if (\preg_match('~(?<width>\d+)px$~', $width, $matches)) {
             $width = (int)$matches['width'];
         } else {
@@ -188,16 +188,6 @@ class HtmlInputNodeImg extends AbstractHtmlInputNode
      */
     protected function mirrorWidthAttribute(\DOMElement $element): void
     {
-        // Aligned images are wrapped in a `<figure>` element that is the target
-        // of the resize operation.
-        if ($element->nodeName !== 'img') {
-            $figure = $this->getParentFigure($element);
-            if ($figure !== null) {
-                $this->mirrorWidthAttribute($figure);
-            }
-            return;
-        }
-
         $width = $element->getAttribute("data-width");
         if ($width && \preg_match('~^\d+px$~', $width)) {
             $style = $element->getAttribute("style");