/** * Assemble variant image data * * @param \XLite\Module\XC\ProductVariants\Model\Image\ProductVariant\Image $image Image * * @return array */ protected function assembleVariantImageData(\XLite\Model\Base\Image $image) { $result = array('full' => array($image->getWidth(), $image->getHeight(), $image->getURL(), $image->getAlt())); foreach ($this->getImageSizes() as $name => $sizes) { $result[$name] = $image->getResizedURL($sizes[0], $sizes[1]); $result[$name][3] = $image->getAlt(); } return $result; }
/** * Renew properties by path * * @param string $path Path * * @return void */ protected function renewByPath($path) { $result = parent::renewByPath($path); return true; }
/** * Get image alternative text * * @param \XLite\Model\Base\Image $image Image * @param integer $i Image index OPTIONAL * * @return string */ public function getAlt($image, $i = null) { return $image && $image->getAlt() ? $image->getAlt() : $this->getProduct()->getName(); }
/** * Get image URL (middle-size) * * @param \XLite\Model\Base\Image $image Image * @param integer $width Width limit OPTIONAL * @param integer $height Height limit OPTIONAL * * @return string */ protected function getMiddleImageURL(\XLite\Model\Base\Image $image, $width = null, $height = null) { $result = $image->getResizedURL($width, $height); return $result[2]; }
/** * Set image * * @param \XLite\Model\Base\Image $image Image * * @return boolean */ public function setImage(\XLite\Model\Base\Image $image) { $this->mimeType = $image->getMime(); $this->width = $image->getWidth(); $this->height = $image->getHeight(); return true; }
/** * Process model * * @param \XLite\Model\Base\Image $model Model * * @return void */ protected function processModel(\XLite\Model\Base\Image $model) { $model->prepareSizes(); }
/** * 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; }