Ejemplo n.º 1
0
 /**
  * @param bool $deferredAllowed
  */
 public function generate($deferredAllowed = true)
 {
     $errorImage = PIMCORE_PATH . '/static6/img/filetype-not-supported.png';
     $deferred = false;
     $generated = false;
     if (!$this->asset) {
         $this->filesystemPath = $errorImage;
     } elseif (!$this->filesystemPath) {
         // if no correct thumbnail config is given use the original image as thumbnail
         if (!$this->config) {
             $fsPath = $this->asset->getFileSystemPath();
             $this->filesystemPath = str_replace(PIMCORE_DOCUMENT_ROOT, "", $fsPath);
         } else {
             try {
                 $deferred = $deferredAllowed && $this->deferred ? true : false;
                 $this->filesystemPath = Thumbnail\Processor::process($this->asset, $this->config, null, $deferred, true, $generated);
             } catch (\Exception $e) {
                 $this->filesystemPath = $errorImage;
                 \Logger::error("Couldn't create thumbnail of image " . $this->asset->getRealFullPath());
                 \Logger::error($e);
             }
         }
     }
     \Pimcore::getEventManager()->trigger("asset.image.thumbnail", $this, ["deferred" => $deferred, "generated" => $generated]);
 }