From 5d0bf3ec233f62c6a5a68629e32b7eaa8c9d1dd3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 27 Apr 2021 14:49:22 +0200 Subject: [PATCH] Delegate smiley HTML generation in HtmlOutputNodeImg to Smiley::getHtml() Resolves #4153 --- .../output/node/HtmlOutputNodeImg.class.php | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php index f6439a609a..72e1968c69 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php @@ -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'); -- 2.20.1