/**
* list of smilies by smiley code
- * @var string[]
+ * @var Smiley[]
*/
protected $smilies = [];
/** @var Smiley $smiley */
foreach ($categorySmilies as $smiley) {
foreach ($smiley->smileyCodes as $smileyCode) {
- $this->smilies[$smileyCode] = $smiley->getURL();
+ $this->smilies[$smileyCode] = $smiley;
}
}
}
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)) {
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);