Exemplo n.º 1
0
 /**
  * Returns a path to a given thumbnail or an thumbnail configuration
  *
  * @param mixed
  * @return string
  */
 public function getThumbnail($thumbnailName)
 {
     $thumbnail = $this->getThumbnailConfig($thumbnailName);
     $path = "";
     if ($thumbnail) {
         try {
             $path = Asset_Image_Thumbnail_Processor::process($this, $thumbnail);
         } catch (Exception $e) {
             Logger::error("Couldn't create thumbnail of image " . $this->getFullPath());
             Logger::error($e);
             return "/pimcore/static/img/image-not-supported.png";
         }
     }
     // if no thumbnail config is given return the original image
     if (empty($path)) {
         $fsPath = $this->getFileSystemPath();
         $path = str_replace(PIMCORE_DOCUMENT_ROOT, "", $fsPath);
         return $path;
     }
     return $path;
 }
Exemplo n.º 2
0
 /**
  * @param $thumbnailName
  */
 public function getImageThumbnail($thumbnailName, $timeOffset = null, $imageAsset = null)
 {
     $cs = $this->getCustomSetting("image_thumbnail_time");
     $im = $this->getCustomSetting("image_thumbnail_asset");
     if (!$timeOffset && !$imageAsset && $cs) {
         $timeOffset = $cs;
     } else {
         if (!$timeOffset && !$imageAsset && $im) {
             $imageAsset = Asset::getById($im);
         }
     }
     // fallback
     if (!$timeOffset && !$imageAsset) {
         $timeOffset = 5;
     }
     if ($imageAsset instanceof Asset_Image) {
         return $imageAsset->getThumbnail($thumbnailName);
     }
     $thumbnail = $this->getImageThumbnailConfig($thumbnailName);
     $thumbnail->setName($thumbnail->getName() . "-" . $timeOffset);
     $converter = Pimcore_Video::getInstance();
     $converter->load($this->getFileSystemPath());
     $path = PIMCORE_TEMPORARY_DIRECTORY . "/video_" . $this->getId() . "__thumbnail_" . $timeOffset . ".png";
     if (!is_file($path)) {
         $converter->saveImage($path, $timeOffset);
     }
     if ($thumbnail) {
         try {
             $path = Asset_Image_Thumbnail_Processor::process($this, $thumbnail, $path);
         } catch (Exception $e) {
             Logger::error("Couldn't create image-thumbnail of video " . $this->getFullPath());
             Logger::error($e);
             return "/pimcore/static/img/filetype-not-supported.png";
         }
     }
     // if no thumbnail config is given return the original image
     if (empty($path)) {
         $fsPath = $this->getFileSystemPath();
         $path = str_replace(PIMCORE_DOCUMENT_ROOT, "", $fsPath);
         return $path;
     }
     return $path;
 }