コード例 #1
0
ファイル: Hotspotimage.php プロジェクト: ptaferner/pimcore
 /**
  * @param null $image
  * @param array $hotspots
  * @param array $marker
  * @param array $crop
  */
 public function __construct($image = null, $hotspots = [], $marker = array(), $crop = array())
 {
     if ($image instanceof Asset\Image) {
         $this->image = $image;
     } else {
         if (is_numeric($image)) {
             $this->image = Asset\Image::getById($image);
         }
     }
     if (is_array($hotspots)) {
         $this->hotspots = array();
         foreach ($hotspots as $h) {
             $this->hotspots[] = $h;
         }
     }
     if (is_array($marker)) {
         $this->marker = array();
         foreach ($marker as $m) {
             $this->marker[] = $m;
         }
     }
     if (is_array($crop)) {
         $this->crop = $crop;
     }
 }
コード例 #2
0
ファイル: Image.php プロジェクト: ptaferner/pimcore
 /**
  * @see Object\ClassDefinition\Data::getDataFromResource
  * @param integer $data
  * @return Asset
  */
 public function getDataFromResource($data)
 {
     if (intval($data) > 0) {
         return Asset\Image::getById($data);
     }
     return null;
 }
コード例 #3
0
ファイル: Image.php プロジェクト: Ahmad-Hilali/pimcore
 /**
  * @return Asset\Image
  */
 public function getImage()
 {
     if (!$this->image) {
         $this->image = Asset\Image::getById($this->getId());
     }
     return $this->image;
 }
コード例 #4
0
 public function getImageThumbnailAction()
 {
     $fileinfo = $this->getParam("fileinfo");
     $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());
         }
     } else {
         // no high-res images in admin mode (editmode)
         // this is mostly because of the document's image editable, which doesn't know anything about the thumbnail
         // configuration, so the dimensions would be incorrect (double the size)
         $thumbnail->setHighResolution(1);
     }
     $format = strtolower($thumbnail->getFormat());
     if ($format == "source" || $format == "print") {
         $thumbnail->setFormat("PNG");
         $format = "png";
     }
     if ($this->getParam("treepreview")) {
         $thumbnail = Asset\Image\Thumbnail\Config::getPreviewConfig();
     }
     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(Tool\Serialize::serialize($this->getAllParams()));
         $thumbnail->setName($thumbnail->getName() . "_auto_" . $hash);
     }
     if ($this->getParam("download")) {
         $downloadFilename = str_replace("." . File::getFileExtension($image->getFilename()), "." . $thumbnail->getFormat(), $image->getFilename());
         $downloadFilename = strtolower($downloadFilename);
         header('Content-Disposition: attachment; filename="' . $downloadFilename . '"');
     }
     $thumbnail = $image->getThumbnail($thumbnail);
     if ($fileinfo) {
         $this->_helper->json(array("width" => $thumbnail->getWidth(), "height" => $thumbnail->getHeight()));
     }
     $thumbnailFile = PIMCORE_DOCUMENT_ROOT . $thumbnail;
     $fileExtension = File::getFileExtension($thumbnailFile);
     if (in_array($fileExtension, array("gif", "jpeg", "jpeg", "png", "pjpeg"))) {
         header("Content-Type: image/" . $fileExtension, true);
     } else {
         header("Content-Type: " . $image->getMimetype(), true);
     }
     header("Content-Length: " . filesize($thumbnailFile), true);
     $this->sendThumbnailCacheHeaders();
     while (@ob_end_flush()) {
     }
     flush();
     readfile($thumbnailFile);
     exit;
 }
コード例 #5
0
ファイル: Image.php プロジェクト: solverat/pimcore
 /** See marshal
  * @param mixed $value
  * @param Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed
  */
 public function unmarshal($value, $object = null, $params = [])
 {
     $id = $value["id"];
     if (intval($id) > 0) {
         return Asset\Image::getById($id);
     }
 }
コード例 #6
0
ファイル: AssetController.php プロジェクト: pimcore/pimcore
 public function getImageThumbnailAction()
 {
     $fileinfo = $this->getParam("fileinfo");
     $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());
         }
     } else {
         // no high-res images in admin mode (editmode)
         // this is mostly because of the document's image editable, which doesn't know anything about the thumbnail
         // configuration, so the dimensions would be incorrect (double the size)
         $thumbnail->setHighResolution(1);
     }
     $format = strtolower($thumbnail->getFormat());
     if ($format == "source" || $format == "print") {
         $thumbnail->setFormat("PNG");
     }
     if ($this->getParam("treepreview")) {
         $thumbnail = Asset\Image\Thumbnail\Config::getPreviewConfig();
     }
     if ($this->getParam("cropPercent")) {
         $thumbnail->addItemAt(0, "cropPercent", ["width" => $this->getParam("cropWidth"), "height" => $this->getParam("cropHeight"), "y" => $this->getParam("cropTop"), "x" => $this->getParam("cropLeft")]);
         $hash = md5(Tool\Serialize::serialize($this->getAllParams()));
         $thumbnail->setName($thumbnail->getName() . "_auto_" . $hash);
     }
     $thumbnail = $image->getThumbnail($thumbnail);
     if ($fileinfo) {
         $this->_helper->json(["width" => $thumbnail->getWidth(), "height" => $thumbnail->getHeight()]);
     }
     $thumbnailFile = $thumbnail->getFileSystemPath();
     header("Content-Type: " . $thumbnail->getMimeType(), true);
     header("Access-Control-Allow-Origin: *");
     // for Aviary.Feather (Adobe Creative SDK)
     header("Content-Length: " . filesize($thumbnailFile), true);
     $this->sendThumbnailCacheHeaders();
     while (@ob_end_flush()) {
     }
     flush();
     readfile($thumbnailFile);
     exit;
 }
コード例 #7
0
ファイル: Image.php プロジェクト: pawansgi92/pimcore2
 /**
  * @param Model\Document\Webservice\Data\Document\Element $wsElement
  * @param null $idMapper
  * @throws \Exception
  */
 public function getFromWebserviceImport($wsElement, $idMapper = null)
 {
     $data = $wsElement->value;
     if ($data->id !== null) {
         $this->alt = $data->alt;
         $this->id = $data->id;
         if ($idMapper) {
             $this->id = $idMapper->getMappedId("asset", $data->id);
         }
         if (is_numeric($this->id)) {
             $this->image = Asset\Image::getById($this->id);
             if (!$this->image instanceof Asset\Image) {
                 if ($idMapper && $idMapper->ignoreMappingFailures()) {
                     $idMapper->recordMappingFailure("document", $this->getDocumentId(), "asset", $data->id);
                 } else {
                     throw new \Exception("cannot get values from web service import - referenced image with id [ " . $this->id . " ] is unknown");
                 }
             }
         } else {
             if ($idMapper && $idMapper->ignoreMappingFailures()) {
                 $idMapper->recordMappingFailure("document", $this->getDocumentId(), "asset", $data->id);
             } else {
                 throw new \Exception("cannot get values from web service import - id is not valid");
             }
         }
     }
 }