From: Alexander Ebert Date: Fri, 1 Feb 2019 11:03:21 +0000 (+0100) Subject: Proper placement of the external link icon for floated images with links X-Git-Tag: 5.2.0_Alpha_1~322 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b320989d8e8a140bff478ce150c478c6e5fd16f6;p=GitHub%2FWoltLab%2FWCF.git Proper placement of the external link icon for floated images with links --- diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php index 4d03b03d4e..bc4cee9f5d 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php @@ -87,5 +87,17 @@ class HtmlOutputNodeA extends AbstractHtmlOutputNode { if (!empty($rel)) { $element->setAttribute('rel', $rel); } + + // If the link contains only a single image that is floated to the right, + // then the external link marker is misaligned. Inheriting the CSS class + // will cause the link marker to behave properly. + if ($element->childNodes->length === 1) { + $child = $element->childNodes->item(0); + if ($child->nodeType === XML_ELEMENT_NODE && $child->nodeName === 'img') { + if (preg_match('~\b(?PmessageFloatObject(?:Left|Right))\b~', $child->getAttribute('class'), $match)) { + $element->setAttribute('class', $element->getAttribute('class') . ' ' . $match['className']); + } + } + } } }