コード例 #1
0
ファイル: ImageRouter.php プロジェクト: vlatosev/filebundle
 /**
  * @param EdImage|null $image
  * @param string $type
  * @param bool|false $absoluteurl
  * @return string
  */
 public function getImageUrl(EdImage $image = null, $type, $absoluteurl = false)
 {
     if (!is_null($image)) {
         $retval = $this->router->generate("edv_show_image", array('namespace' => $image->getFile()->getFileNamespace(), 'image_hash' => $image->getHashString(), 'image_thumb' => $type . '.' . $image->getExtension()), $absoluteurl ? UrlGeneratorInterface::ABSOLUTE_URL : UrlGeneratorInterface::ABSOLUTE_PATH);
         $this->registrator->register($image, $type);
     } else {
         $retval = $this->router->generate("edv_show_default_image", array('image_thumb' => $type . '.' . $this->processor->getDefaultExtension($type)), $absoluteurl ? UrlGeneratorInterface::ABSOLUTE_URL : UrlGeneratorInterface::ABSOLUTE_PATH);
     }
     return $retval;
 }
コード例 #2
0
ファイル: ImageManager.php プロジェクト: vlatosev/filebundle
 public function updateImage(EdImage $image, EntityManagerInterface $em)
 {
     $source = $image->getFile()->getUploadFile();
     if ($source instanceof File) {
         $imagine = $this->imgproc->getImagine();
         $file = $imagine->open($source->getPathname());
         $island = $this->imgproc->isLandscapeOrient($file);
         if ($island) {
             $image->setWidth($file->getSize()->getWidth());
             $image->setHeight($file->getSize()->getHeight());
         } else {
             $image->setHeight($file->getSize()->getWidth());
             $image->setWidth($file->getSize()->getHeight());
         }
         $image->setProcessed(true);
         $image->setHashString($this->getUniqueCachedName($em));
         $image->setArea([]);
     }
 }