Added missing HD versions for auto-detected smilies
authorAlexander Ebert <ebert@woltlab.com>
Sat, 22 Oct 2016 16:20:31 +0000 (18:20 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 22 Oct 2016 16:20:31 +0000 (18:20 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php

index 2905f9a6c3c4da4e24661eb275671fd888d1b6ab..fc41905399f42d8a8206813c341515f893afb709 100644 (file)
@@ -39,7 +39,7 @@ class HtmlInputNodeTextParser {
        
        /**
         * list of smilies by smiley code
-        * @var string[]
+        * @var Smiley[]
         */
        protected $smilies = [];
        
@@ -92,7 +92,7 @@ class HtmlInputNodeTextParser {
                                /** @var Smiley $smiley */
                                foreach ($categorySmilies as $smiley) {
                                        foreach ($smiley->smileyCodes as $smileyCode) {
-                                               $this->smilies[$smileyCode] = $smiley->getURL();
+                                               $this->smilies[$smileyCode] = $smiley;
                                        }
                                }
                        }
@@ -434,7 +434,7 @@ class HtmlInputNodeTextParser {
                static $smileyPattern = null;
                if ($smileyPattern === null) {
                        $difficultCodes = [];
-                       foreach ($this->smilies as $smileyCode => $url) {
+                       foreach ($this->smilies as $smileyCode => $smiley) {
                                $smileyCode = preg_quote($smileyCode, '~');
                                
                                if (!preg_match('~^\\\:.+\\\:$~', $smileyCode)) {
@@ -457,10 +457,15 @@ class HtmlInputNodeTextParser {
                return preg_replace_callback($smileyPattern, function($matches) use ($text) {
                        $smileyCode = $matches[0];
                        
+                       $smiley = $this->smilies[$smileyCode];
                        $element = $text->ownerDocument->createElement('img');
-                       $element->setAttribute('src', $this->smilies[$smileyCode]);
+                       $element->setAttribute('src', $smiley->getURL());
                        $element->setAttribute('class', 'smiley');
                        $element->setAttribute('alt', $smileyCode);
+                       $element->setAttribute('height', $smiley->getHeight());
+                       if ($smiley->getURL2x()) {
+                               $element->setAttribute('srcset', $smiley->getURL2x() . ' 2x');
+                       }
                        
                        return $this->addReplacement($text, $element);
                }, $value);