Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
image.php
1<?php
2
4
6
7class Image extends Renderer
8{
9 const WIDTH = 1920;
10 const HEIGHT = 1080;
11
12 const JS_TYPE_IMAGE = 'image';
13
14 public function getWidth()
15 {
16 return $this->getOption('width', self::WIDTH);
17 }
18
19 public function getHeight()
20 {
21 return $this->getOption('height', self::HEIGHT);
22 }
23
24 public function getOriginalImage()
25 {
26 return $this->getOption('originalImage');
27 }
28
29 public static function getJsType()
30 {
32 }
33
34 public static function getAllowedContentTypes()
35 {
36 return [
37 'image/gif',
38 'image/jpeg',
39 'image/webp',
40 'image/bmp',
41 'image/png',
42 ];
43 }
44
45 public function render()
46 {
47 $imageFile = $this->getOriginalImage();
48 if (!$imageFile)
49 {
50 return null;
51 }
52
53 $resizedImage = new ResizedImage($imageFile, $this->getWidth(), $this->getHeight());
54 $resizedImage->setResizeType(BX_RESIZE_IMAGE_PROPORTIONAL);
55
56 return $resizedImage;
57 }
58}
getOption($name, $defaultValue=null)
Definition renderer.php:25