Ejemplo n.º 1
0
 /**
  * Set image
  *
  * @param \XLite\Model\Base\Image $image Image
  *
  * @return boolean
  */
 public function setImage(\XLite\Model\Base\Image $image)
 {
     $this->image = null;
     $result = parent::setImage($image);
     if ($result && $this->getImageType() && $image->getBody()) {
         $func = 'imagecreatefrom' . $this->getImageType();
         if (function_exists($func)) {
             $data = $image->getBody();
             $fn = tempnam(LC_DIR_TMP, 'image');
             file_put_contents($fn, $data);
             unset($data);
             // $func is assembled from 'imagecreatefrom' + image type
             $this->image = @$func($fn);
             unlink($fn);
             $result = (bool) $this->image;
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Set image
  *
  * @param \XLite\Model\Base\Image $image Image
  *
  * @return void
  */
 public function setImage(\XLite\Model\Base\Image $image)
 {
     parent::setImage($image);
     $this->image = tempnam(LC_DIR_TMP, 'image');
     file_put_contents($this->image, $image->getBody());
 }