Пример #1
0
 /**
  * Constructor: sets the url and path properties based on the arguments
  *
  * @param File $file (optional) A File entity from which we'll calculate the
  *   thumbnail url and path.
  */
 public function __construct(File $file = NULL)
 {
     $this->setDefault();
     if ($file) {
         if (!$file->exists()) {
             $this->setMissing();
         } elseif ($file->isImage()) {
             $this->url = rtrim($file->getUploadDestination()->url, '/') . '/_thumbs/' . rawurlencode($file->file_name);
             $this->path = rtrim($file->getUploadDestination()->server_path, '/') . '/_thumbs/' . rawurlencode($file->file_name);
         }
     }
 }
Пример #2
0
 public function make(File $file)
 {
     // We only make thumbnails of images
     if ($file->isImage()) {
         ee()->load->library('filemanager');
         $dir = $file->UploadDestination;
         $dimensions = $dir->FileDimensions;
         $success = ee()->filemanager->create_thumb($file->getAbsolutePath(), array('server_path' => $dir->server_path, 'file_name' => $file->file_name, 'dimensions' => $dimensions->asArray()), TRUE, FALSE);
     }
     $thumb = new Thumbnail($file);
     return $thumb;
 }