Example #1
0
 /**
  * @param File $file
  * @return string
  */
 protected function getThumbnailURLForFile(File $file)
 {
     if ($file->exists() && file_exists(Director::baseFolder() . '/' . $file->getFilename())) {
         $width = $this->getPreviewMaxWidth();
         $height = $this->getPreviewMaxHeight();
         if ($file->hasMethod('getThumbnail')) {
             return $file->getThumbnail($width, $height)->getURL();
         } elseif ($file->hasMethod('getThumbnailURL')) {
             return $file->getThumbnailURL($width, $height);
         } elseif ($file->hasMethod('SetRatioSize')) {
             return $file->SetRatioSize($width, $height)->getURL();
         } else {
             return $file->Icon();
         }
     }
     return false;
 }
Example #2
0
 /**
  * @param File $file
  * @return string
  */
 protected function getThumbnailURLForFile(File $file)
 {
     if ($file && $file->exists() && file_exists(Director::baseFolder() . '/' . $file->getFilename())) {
         if ($file->hasMethod('getThumbnail')) {
             return $file->getThumbnail($this->getConfig('previewMaxWidth'), $this->getConfig('previewMaxHeight'))->getURL();
         } elseif ($file->hasMethod('getThumbnailURL')) {
             return $file->getThumbnailURL($this->getConfig('previewMaxWidth'), $this->getConfig('previewMaxHeight'));
         } elseif ($file->hasMethod('SetRatioSize')) {
             return $file->SetRatioSize($this->getConfig('previewMaxWidth'), $this->getConfig('previewMaxHeight'))->getURL();
         } else {
             return $file->Icon();
         }
     }
     return false;
 }