/**
  * Enregistre la miniature de l'illustration sur le serveur.
  * 
  * @param \Lyssal\CollectionBundle\Entity\Illustration $illustration Illustration originale
  * @return \Lyssal\Image L'image miniature créée
  */
 protected function createImageMiniature(Illustration $illustration)
 {
     $imageOriginale = new Image($this->kernelRootDir . '/../web/' . $illustration->getImageChemin());
     $imageMiniature = $imageOriginale->copy($this->kernelRootDir . '/../web/' . $illustration->getImageChemin(), false);
     if (null === $imageMiniature) {
         throw new \Exception('Impossible d\'enregistrer la miniature.');
     }
     if ($imageMiniature->getLargeur() > $imageMiniature->getHauteur()) {
         $imageMiniature->redimensionne(Illustration::$MINIATURE_LARGEUR_MAXIMALE, null);
     } else {
         $imageMiniature->redimensionne(null, Illustration::$MINIATURE_HAUTEUR_MAXIMALE);
     }
     return $imageMiniature;
 }
Example #2
0
 /**
  * Add illustrations
  *
  * @param \Lyssal\CollectionBundle\Entity\Illustration $illustrations
  * @return Element
  */
 public function addIllustration(\Lyssal\CollectionBundle\Entity\Illustration $illustration)
 {
     if (null === $illustration->getElement()) {
         $illustration->setElement($this);
     }
     $this->illustrations[] = $illustration;
     return $this;
 }
 /**
  * Retourne le titre de l'image.
  * 
  * @return string Titre
  */
 public function getTitle()
 {
     if (null !== $this->rectoElement) {
         return $this->rectoElement->getNom();
     }
     if (null !== $this->versoElement) {
         return $this->versoElement->getNom();
     }
     if (null !== $this->element) {
         return $this->element->getNom();
     }
     if (null !== $this->originale) {
         return $this->originale->getTitle();
     }
     if (null !== $this->image) {
         return false !== strpos($this->image, '.') ? substr($this->image, 0, strrpos($this->image, '.')) : $this->image;
     }
     return '#' . $this->id;
 }