/**
*
*/
public function dispatchLoopShutdown()
{
if (!Asset\Image\Thumbnail::isPictureElementInUse()) {
return;
}
if (!Asset\Image\Thumbnail::getEmbedPicturePolyfill()) {
return;
}
if (!\Pimcore\Tool::isHtmlResponse($this->getResponse())) {
return;
}
// analytics
$body = $this->getResponse()->getBody();
// search for the end <head> tag, and insert the google analytics code before
// this method is much faster than using simple_html_dom and uses less memory
$code = '<script type="text/javascript" src="/pimcore/static/js/frontend/picturePolyfill.min.js" defer></script>';
$headEndPosition = stripos($body, "</head>");
if ($headEndPosition !== false) {
$body = substr_replace($body, $code . "</head>", $headEndPosition, 7);
}
$this->getResponse()->setBody($body);
}