示例#1
0
 public function get(File $file = NULL)
 {
     $thumb = new Thumbnail($file);
     // If the thumbnail is missing, and this is an image file generate
     // the thumbnail now
     if (!$thumb->exists() && $file && $file->exists() && $file->isImage()) {
         $thumb = $this->make($file);
     }
     return $thumb;
 }
示例#2
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);
         }
     }
 }