Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/engine/response/ |
Upload File : |
<?php namespace Bitrix\Main\Engine\Response; use Bitrix\Main; class ResizedImage extends BFile { protected $showInline = true; protected $width; protected $height; protected $resizeType = BX_RESIZE_IMAGE_EXACT; protected $filters; public function __construct(array $file, $width, $height, $name = null) { parent::__construct($file, $name); $this->setWidth($width); $this->setHeight($height); } public static function createByImageId($imageId, $width, $height, $name = null) { $imageData = \CFile::getFileArray($imageId); if (!$imageData) { throw new Main\ObjectNotFoundException("Could not find file"); } return new self($imageData, $width, $height, $name); } public static function createByImageData(array $imageData, $width, $height, $name = null) { return new self($imageData, $width, $height, $name); } /** * @return mixed */ public function getWidth() { return $this->width; } /** * @param mixed $width * * @return ResizedImage */ public function setWidth($width) { $this->width = $width; return $this; } /** * @return mixed */ public function getHeight() { return $this->height; } /** * @param mixed $height * * @return ResizedImage */ public function setHeight($height) { $this->height = $height; return $this; } /** * @return int */ public function getResizeType() { return $this->resizeType; } /** * @param int $resizeType * * @return ResizedImage */ public function setResizeType($resizeType) { $this->resizeType = $resizeType; return $this; } /** * @return mixed */ public function getFilters() { return $this->filters; } /** * @param mixed $filters * * @return ResizedImage */ public function setFilters($filters) { $this->filters = $filters; return $this; } /** * @return array */ public function getImage() { return $this->file; } protected function prepareFile() { $file = parent::prepareFile(); $tmpFile = \CFile::resizeImageGet( $file, ['width' => $this->getWidth(), 'height' => $this->getHeight()], $this->getResizeType(), true, $this->getFilters(), true ); $file['FILE_SIZE'] = $tmpFile['size']; $file['SRC'] = $tmpFile['src']; return $file; } }