Example #1
0
 /**
  * Resize icon
  *
  * @param integer $width  Destination width
  * @param integer $height Destination height
  * @param string  $path   Write path
  *
  * @return array
  */
 protected function resizeIcon($width, $height, $path)
 {
     $operator = new \XLite\Core\ImageOperator($this);
     list($newWidth, $newHeight, $result) = $operator->resizeDown($width, $height);
     return false !== $result && \Includes\Utils\FileManager::write($path, $operator->getImage()) ? array($newWidth, $newHeight) : null;
 }
Example #2
0
 /**
  * Resize icon
  *
  * @param integer $width  Destination width
  * @param integer $height Destination height
  * @param string  $path   Write path
  *
  * @return array
  */
 protected function resizeIcon($width, $height, $path)
 {
     $result = null;
     if ($this->isUseS3Icons()) {
         $operator = new \XLite\Core\ImageOperator($this);
         list($newWidth, $newHeight, $r) = $operator->resizeDown($width, $height);
         if (false !== $r) {
             $basename = $this->getFileName() ?: basename($this->getPath());
             $headers = array('Content-Type' => $this->getMime(), 'Content-Disposition' => 'inline; filename="' . $basename . '"');
             if ($this->getS3()->write($path, $operator->getImage(), $headers)) {
                 $icons = $this->getS3Icons();
                 $icons[$path] = true;
                 $this->setS3Icons($icons);
                 \XLite\Core\Database::getEM()->flush();
                 $result = array($newWidth, $newHeight);
             }
         }
     } else {
         $result = parent::resizeIcon($width, $height, $path);
     }
     return $result;
 }