* Returns the html code to render the smiley.
*
* @param string $class (additional) class(es) of the smiley element
+ * @param bool $isAmp
* @return string
*/
- public function getHtml($class = '')
+ public function getHtml($class = '', $isAmp = false)
{
$srcset = ($this->smileyPath2x) ? ' srcset="' . StringUtil::encodeHTML($this->getURL2x()) . ' 2x"' : '';
$height = ($this->getHeight()) ? ' height="' . $this->getHeight() . '"' : '';
$class = ' ' . $class;
}
- return '<img src="' . StringUtil::encodeHTML($this->getURL()) . '" alt="' . StringUtil::encodeHTML($this->smileyCode) . '" title="' . WCF::getLanguage()->get($this->smileyTitle) . '" class="smiley' . $class . '"' . $srcset . $height . $width . ' loading="eager">';
+ $loading = ($isAmp) ? '' : ' loading="eager"';
+
+ return '<img src="' . StringUtil::encodeHTML($this->getURL()) . '" alt="' . StringUtil::encodeHTML($this->smileyCode) . '" title="' . WCF::getLanguage()->get($this->smileyTitle) . '" class="smiley' . $class . '"' . $srcset . $height . $width . $loading . '>';
}
}
*/
public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor)
{
+ $isAmp = ($htmlNodeProcessor instanceof AmpHtmlOutputNodeProcessor);
+
/** @var \DOMElement $element */
foreach ($elements as $element) {
$class = $element->getAttribute('class');
} else {
// Ensure that the smiley's HTML is up to date.
$doc = new \DOMDocument();
- $doc->loadHTML($smiley->getHtml());
+ $doc->loadHTML($smiley->getHtml('', $isAmp));
$smileyNode = $element->ownerDocument->importNode($doc->getElementsByTagName('img')->item(0), true);
$element->parentNode->replaceChild($smileyNode, $element);
}