Delegate smiley HTML generation in HtmlOutputNodeImg to Smiley::getHtml()
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 27 Apr 2021 12:49:22 +0000 (14:49 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 27 Apr 2021 12:51:32 +0000 (14:51 +0200)
Resolves #4153

wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php

index f6439a609a6698a7e9cccdefe9f73013dfcceccc..72e1968c69601b8022eeb0e428d8dd87cd61c151 100644 (file)
@@ -48,22 +48,11 @@ class HtmlOutputNodeImg extends AbstractHtmlOutputNode
                     // output as raw code instead
                     $htmlNodeProcessor->replaceElementWithText($element, ' ' . $code . ' ', false);
                 } else {
-                    // enforce database values for src, srcset and style
-                    $element->setAttribute('src', $smiley->getURL());
-
-                    if ($smiley->getHeight()) {
-                        $element->setAttribute('height', (string)$smiley->getHeight());
-                    } else {
-                        $element->removeAttribute('height');
-                    }
-
-                    if ($smiley->smileyPath2x) {
-                        $element->setAttribute('srcset', $smiley->getURL2x() . ' 2x');
-                    } else {
-                        $element->removeAttribute('srcset');
-                    }
-
-                    $element->setAttribute('title', WCF::getLanguage()->get($smiley->smileyTitle));
+                    // Ensure that the smiley's HTML is up to date.
+                    $doc = new \DOMDocument();
+                    $doc->loadHTML($smiley->getHtml());
+                    $smileyNode = $element->ownerDocument->importNode($doc->getElementsByTagName('img')->item(0), true);
+                    $element->parentNode->replaceChild($smileyNode, $element);
                 }
             } else {
                 $src = $element->getAttribute('src');