Proper placement of the external link icon for floated images with links
authorAlexander Ebert <ebert@woltlab.com>
Fri, 1 Feb 2019 11:03:21 +0000 (12:03 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 1 Feb 2019 11:03:21 +0000 (12:03 +0100)
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php

index 4d03b03d4ef64b47b94d23c1b906b89650646879..bc4cee9f5d908349d24286634b4b96785e8cefd2 100644 (file)
@@ -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(?P<className>messageFloatObject(?:Left|Right))\b~', $child->getAttribute('class'), $match)) {
+                                       $element->setAttribute('class', $element->getAttribute('class') . ' ' . $match['className']);
+                               }
+                       }
+               }
        }
 }