/** * */ 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); }
/** * @see Document\Tag\TagInterface::frontend * @return string */ public function frontend() { if (!is_array($this->options)) { $this->options = []; } $image = $this->getImage(); if ($image instanceof Asset) { if (isset($this->options["thumbnail"]) && $this->options["thumbnail"] || $this->cropPercent) { // create a thumbnail first $autoName = false; $thumbConfig = $image->getThumbnailConfig($this->options["thumbnail"]); if (!$thumbConfig && $this->cropPercent) { $thumbConfig = new Asset\Image\Thumbnail\Config(); } if ($this->cropPercent) { $this->applyCustomCropping($thumbConfig); $autoName = true; } if (isset($this->options["highResolution"]) && $this->options["highResolution"] > 1) { $thumbConfig->setHighResolution($this->options["highResolution"]); } // autogenerate a name for the thumbnail because it's different from the original if ($autoName) { $hash = md5(Serialize::serialize($thumbConfig->getItems())); $thumbConfig->setName($thumbConfig->getName() . "_auto_" . $hash); } $deferred = true; if (isset($this->options["deferred"])) { $deferred = $this->options["deferred"]; } $thumbnail = $image->getThumbnail($thumbConfig, $deferred); } else { // we're using the thumbnail class only to generate the HTML $thumbnail = new Asset\Image\Thumbnail($image); } $attributes = array_merge($this->options, ["alt" => $this->alt, "title" => $this->alt]); $removeAttributes = []; if (isset($this->options["removeAttributes"]) && is_array($this->options["removeAttributes"])) { $removeAttributes = $this->options["removeAttributes"]; } // thumbnail's HTML is always generated by the thumbnail itself return $thumbnail->getHTML($attributes, $removeAttributes); } }