/** * */ public function generate($deferredAllowed = false) { if (!$this->path) { // if no correct thumbnail config is given use the original image as thumbnail if (!$this->config) { $fsPath = $this->asset->getFileSystemPath(); $this->path = str_replace(PIMCORE_DOCUMENT_ROOT, "", $fsPath); } else { try { $deferred = $deferredAllowed && $this->deferred ? true : false; $this->path = Thumbnail\Processor::process($this->asset, $this->config, null, $deferred); } catch (\Exception $e) { $this->path = '/pimcore/static/img/filetype-not-supported.png'; \Logger::error("Couldn't create thumbnail of image " . $this->asset->getFullPath()); \Logger::error($e); } } } }
/** * Get the height of the generated thumbnail image in pixels. * @return string HTTP Mime Type of the generated thumbnail image. */ public function getMimeType() { if (!$this->mimetype) { // get target mime type without actually generating the thumbnail (deferred) $mapping = ["png" => "image/png", "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "pjpeg" => "image/jpeg", "gif" => "image/gif", "tiff" => "image/tiff", "svg" => "image/svg+xml"]; $targetFormat = strtolower($this->getConfig()->getFormat()); $format = $targetFormat; $fileExt = \Pimcore\File::getFileExtension($this->getAsset()->getFilename()); if ($targetFormat == "source" || empty($targetFormat)) { $format = Thumbnail\Processor::getAllowedFormat($fileExt, ["jpeg", "gif", "png"], "png"); } elseif ($targetFormat == "print") { $format = Thumbnail\Processor::getAllowedFormat($fileExt, ["svg", "jpeg", "png", "tiff"], "png"); if (($format == "tiff" || $format == "svg") && \Pimcore\Tool::isFrontentRequestByAdmin()) { // return a webformat in admin -> tiff cannot be displayed in browser $format = "png"; } } if (array_key_exists($format, $mapping)) { $this->mimetype = $mapping[$format]; } else { // unknown $this->mimetype = "application/octet-stream"; } } return $this->mimetype; }