protected function showImage(Application $app, File $file, $mode)
 {
     if (null === $file->getThumbnailPath()) {
         return $app->redirect("/file/{$file->getId()}");
     }
     $ext = $file->getExtension();
     $ext = $ext === "jpg" ? "jpeg" : $ext;
     $imagecreate = "imagecreatefrom{$ext}";
     $image = "image{$ext}";
     switch ($mode) {
         case 'thumb':
             $im = $imagecreate("{$app['file.save_directory']}/{$file->getThumbnailPath()}");
             break;
         case 'original':
             $im = $imagecreate("{$app['file.save_directory']}/{$file->getPath()}");
             break;
     }
     return new Response($image($im), 200, array("Content-Type" => "{$file->getMimeType()}"));
 }
Esempio n. 2
0
 public function isImage(File $file)
 {
     return in_array($file->getExtension(), $this->imageExtensions);
 }
 public function setSourceImageFile(\Filehosting\Model\File $file)
 {
     $this->sourceImageFile = $file;
     $this->imageExtension = $file->getExtension();
 }