Exemple #1
0
 /**
  * Preprocess default image
  *
  * @return void
  */
 protected function processDefaultImage()
 {
     list($this->properties['width'], $this->properties['height']) = \XLite\Core\ImageOperator::getCroppedDimensions(\XLite::getInstance()->getOptions(array('images', 'default_image_width')), \XLite::getInstance()->getOptions(array('images', 'default_image_height')), max(0, $this->getParam(self::PARAM_MAX_WIDTH)), max(0, $this->getParam(self::PARAM_MAX_HEIGHT)));
     // Center the image vertically and horizontally
     if ($this->getParam(self::PARAM_CENTER_IMAGE)) {
         $this->setImagePaddings();
     }
 }
Exemple #2
0
 /**
  * Get resized image URL
  *
  * @param integer $width  Width limit OPTIONAL
  * @param integer $height Height limit OPTIONAL
  *
  * @return array (new width + new height + URL)
  */
 public function getResizedURL($width = null, $height = null)
 {
     $size = ($width ?: 'x') . '.' . ($height ?: 'x');
     $name = $this->getId() . '.' . $this->getExtension();
     $path = $this->getResizedPath($size, $name);
     $url = $this->getResizedPublicURL($size, $name);
     list($newWidth, $newHeight) = \XLite\Core\ImageOperator::getCroppedDimensions($this->getWidth(), $this->getHeight(), $width, $height);
     if (!$this->isResizedIconAvailable($path)) {
         $result = $this->resizeIcon($newWidth, $newHeight, $path);
         if (!$result) {
             $url = $this->getURL();
         }
     }
     return array($newWidth, $newHeight, $url);
 }
Exemple #3
0
 /**
  * Do resize
  *
  * @param integer $width     Width limit OPTIONAL
  * @param integer $height    Height limit OPTIONAL
  * @param boolean $doRewrite Rewrite flag OPTIONAL
  *
  * @return array
  */
 public function doResize($width = null, $height = null, $doRewrite = false)
 {
     $name = pathinfo($this->getPath(), \PATHINFO_FILENAME) . '.' . $this->getExtension();
     $size = ($width ?: 'x') . '.' . ($height ?: 'x');
     $path = $this->getResizedPath($size, $name);
     list($newWidth, $newHeight) = \XLite\Core\ImageOperator::getCroppedDimensions($this->getWidth(), $this->getHeight(), $width, $height);
     $url = $this->getResizedPublicURL($size, $name);
     if (!$this->isResizedIconAvailable($path) || $doRewrite) {
         $result = $this->resizeIcon($newWidth, $newHeight, $path);
         if (!$result) {
             $url = $this->getURL();
         }
     } elseif (!$this->isResizedIconAvailable($path)) {
         $url = $this->getURL();
     }
     return array($newWidth, $newHeight, $url);
 }
Exemple #4
0
 /**
  * Preprocess default image
  *
  * @return void
  */
 protected function processDefaultImage()
 {
     list($this->properties['width'], $this->properties['height']) = \XLite\Core\ImageOperator::getCroppedDimensions(static::DEFAULT_IMAGE_WIDTH, static::DEFAULT_IMAGE_HEIGHT, max(0, $this->getParam(self::PARAM_MAX_WIDTH)), max(0, $this->getParam(self::PARAM_MAX_HEIGHT)));
     // Center the image vertically and horizontally
     if ($this->getParam(self::PARAM_CENTER_IMAGE)) {
         $this->setImageMargin();
     }
 }