Esempio n. 1
0
 /**
  * Creates an image from a file.
  *
  * @param string $filePath
  * @param string $baseMime (image|video)
  *
  * @return null|string $thumnnailPath
  */
 public function createFromFile($filePath, $baseMime, Workspace $workspace = null)
 {
     $ds = DIRECTORY_SEPARATOR;
     if (is_null($workspace)) {
         $prefix = $this->thumbDir;
     } else {
         $prefix = $this->thumbDir . $ds . $workspace->getCode();
         if (!is_dir($prefix)) {
             @mkdir($prefix);
         }
     }
     $newPath = $prefix . $ds . $this->ut->generateGuid() . ".png";
     $thumbnailPath = null;
     if ($baseMime === 'video') {
         try {
             $thumbnailPath = $this->creator->fromVideo($filePath, $newPath, 100, 100);
         } catch (\Exception $e) {
             $thumbnailPath = null;
             //error handling ? $thumbnailPath = null
         }
     }
     if ($baseMime === 'image') {
         try {
             $thumbnailPath = $this->creator->fromImage($filePath, $newPath, 100, 100);
         } catch (\Exception $e) {
             $thumbnailPath = null;
             //error handling ? $thumbnailPath = null
         }
     }
     return $thumbnailPath;
 }
Esempio n. 2
0
 private function createShortcutFromRelativeUrl($url, $workspace = null)
 {
     $ds = DIRECTORY_SEPARATOR;
     try {
         $originalIconLocation = "{$this->rootDir}{$ds}..{$ds}web{$ds}{$url}";
         $shortcutLocation = $this->creator->shortcutThumbnail($originalIconLocation, $workspace);
     } catch (\Exception $e) {
         $shortcutLocation = "{$this->rootDir}{$ds}.." . "{$ds}web{$ds}bundles{$ds}clarolinecore{$ds}images{$ds}resources{$ds}icons{$ds}shortcut-default.png";
     }
     if (strstr($shortcutLocation, "bundles")) {
         $tmpRelativeUrl = strstr($shortcutLocation, "bundles");
     } else {
         $tmpRelativeUrl = strstr($shortcutLocation, $this->basepath);
     }
     return str_replace('\\', '/', $tmpRelativeUrl);
 }