Ejemplo n.º 1
0
 public function __construct($image, $hotspots)
 {
     if ($image instanceof Asset_Image) {
         $this->image = $image;
     } else {
         $this->image = Asset_Image::getById($image);
     }
     if (is_array($hotspots)) {
         $this->hotspots = array();
         foreach ($hotspots as $h) {
             $this->hotspots[] = $h;
         }
     }
 }
Ejemplo n.º 2
0
 public function getImageThumbnailAction()
 {
     $image = Asset_Image::getById(intval($this->_getParam("id")));
     $thumbnail = null;
     if ($this->_getParam("thumbnail")) {
         $thumbnail = $image->getThumbnailConfig($this->_getParam("thumbnail"));
     }
     if (!$thumbnail) {
         if ($this->_getParam("config")) {
             $thumbnail = $image->getThumbnailConfig(Zend_Json::decode($this->_getParam("config")));
         } else {
             $thumbnail = $image->getThumbnailConfig($this->_getAllParams());
         }
     }
     $format = strtolower($thumbnail->getFormat());
     if ($format == "source") {
         $thumbnail->setFormat("PNG");
         $format = "png";
     }
     if ($this->_getParam("cropPercent")) {
         $thumbnail->addItemAt(0, "cropPercent", array("width" => $this->_getParam("cropWidth"), "height" => $this->_getParam("cropHeight"), "y" => $this->_getParam("cropTop"), "x" => $this->_getParam("cropLeft")));
         $hash = md5(Pimcore_Tool_Serialize::serialize($this->_getAllParams()));
         $thumbnail->setName("auto_" . $hash);
     }
     $this->getResponse()->setHeader("Content-Type", "image/" . $format, true);
     if ($this->_getParam("download")) {
         $this->getResponse()->setHeader("Content-Disposition", 'attachment; filename="' . $image->getFilename() . '"');
     }
     $thumbnailFile = PIMCORE_DOCUMENT_ROOT . $image->getThumbnail($thumbnail);
     $imageContent = file_get_contents($thumbnailFile);
     $fileExtension = Pimcore_File::getFileExtension($thumbnailFile);
     if (in_array($fileExtension, array("gif", "jpeg", "jpeg", "png"))) {
         header("Content-Type: image/" . $fileExtension);
     } else {
         header("Content-Type: " . $image->getMimetype());
     }
     header("Content-Length: " . filesize($thumbnailFile));
     echo $imageContent;
     exit;
 }
Ejemplo n.º 3
0
 /**
  * Receives a Webservice_Data_Document_Element from webservice import and fill the current tag's data
  *
  * @abstract
  * @param  Webservice_Data_Document_Element $data
  * @return void
  */
 public function getFromWebserviceImport($wsElement)
 {
     $data = $wsElement->value;
     if ($data->id !== null) {
         $this->alt = $data->alt;
         $this->id = $data->id;
         if (is_numeric($this->id)) {
             $this->image = Asset_Image::getById($this->id);
             if (!$this->image instanceof Asset_Image) {
                 throw new Exception("cannot get values from web service import - referenced image with id [ " . $this->id . " ] is unknown");
             }
         } else {
             throw new Exception("cannot get values from web service import - id is not valid");
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @see Object_Class_Data::getDataFromResource
  * @param integer $data
  * @return Asset
  */
 public function getDataFromResource($data)
 {
     if (intval($data) > 0) {
         return Asset_Image::getById($data);
     }
     return null;
 }
Ejemplo n.º 5
0
 public function getImageThumbnailAction()
 {
     $image = Asset_Image::getById(intval($this->_getParam("id")));
     $thumbnail = null;
     if ($this->_getParam("thumbnail")) {
         $thumbnail = $image->getThumbnailConfig($this->_getParam("thumbnail"));
     }
     if (!$thumbnail) {
         if ($this->_getParam("config")) {
             $thumbnail = $image->getThumbnailConfig(Zend_Json::decode($this->_getParam("config")));
         } else {
             $thumbnail = $image->getThumbnailConfig($this->_getAllParams());
         }
     }
     $format = strtolower($thumbnail->getFormat());
     if ($format == "source") {
         $thumbnail->setFormat("PNG");
         $format = "png";
     }
     if ($this->_getParam("cropPercent")) {
         $thumbnail->addItemAt(0, "cropPercent", array("width" => $this->_getParam("cropWidth"), "height" => $this->_getParam("cropHeight"), "y" => $this->_getParam("cropTop"), "x" => $this->_getParam("cropLeft")));
         $hash = md5(Pimcore_Tool_Serialize::serialize($this->_getAllParams()));
         $thumbnail->setName("auto_" . $hash);
     }
     $this->getResponse()->setHeader("Content-Type", "image/" . $format, true);
     if ($this->_getParam("download")) {
         $this->getResponse()->setHeader("Content-Disposition", 'attachment; filename="' . $image->getFilename() . '"');
     }
     readfile(PIMCORE_DOCUMENT_ROOT . $image->getThumbnail($thumbnail));
     $this->removeViewRenderer();
 }