|
3 | 3 | * Copyright © Magento, Inc. All rights reserved. |
4 | 4 | * See COPYING.txt for license details. |
5 | 5 | */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
6 | 8 | namespace Magento\Backend\Block\Media; |
7 | 9 |
|
8 | 10 | use Magento\Framework\App\ObjectManager; |
9 | 11 | use Magento\Framework\Serialize\Serializer\Json; |
| 12 | +use Magento\Framework\Image\Adapter\ConfigInterface; |
10 | 13 |
|
11 | 14 | /** |
12 | 15 | * Adminhtml media library uploader |
@@ -35,20 +38,29 @@ class Uploader extends \Magento\Backend\Block\Widget |
35 | 38 | */ |
36 | 39 | private $jsonEncoder; |
37 | 40 |
|
| 41 | + /** |
| 42 | + * @var ConfigInterface |
| 43 | + */ |
| 44 | + private $imageConfig; |
| 45 | + |
38 | 46 | /** |
39 | 47 | * @param \Magento\Backend\Block\Template\Context $context |
40 | 48 | * @param \Magento\Framework\File\Size $fileSize |
41 | 49 | * @param array $data |
42 | 50 | * @param Json $jsonEncoder |
| 51 | + * @param ConfigInterface $imageConfig |
43 | 52 | */ |
44 | 53 | public function __construct( |
45 | 54 | \Magento\Backend\Block\Template\Context $context, |
46 | 55 | \Magento\Framework\File\Size $fileSize, |
47 | 56 | array $data = [], |
48 | | - Json $jsonEncoder = null |
| 57 | + Json $jsonEncoder = null, |
| 58 | + ConfigInterface $imageConfig = null |
49 | 59 | ) { |
50 | 60 | $this->_fileSizeService = $fileSize; |
51 | 61 | $this->jsonEncoder = $jsonEncoder ?: ObjectManager::getInstance()->get(Json::class); |
| 62 | + $this->imageConfig = $imageConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class); |
| 63 | + |
52 | 64 | parent::__construct($context, $data); |
53 | 65 | } |
54 | 66 |
|
@@ -90,6 +102,26 @@ public function getFileSizeService() |
90 | 102 | return $this->_fileSizeService; |
91 | 103 | } |
92 | 104 |
|
| 105 | + /** |
| 106 | + * Get Image Upload Maximum Width Config |
| 107 | + * |
| 108 | + * @return int |
| 109 | + */ |
| 110 | + public function getImageUploadMaxWidth() |
| 111 | + { |
| 112 | + return $this->imageConfig->getMaxWidth(); |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Get Image Upload Maximum Height Config |
| 117 | + * |
| 118 | + * @return int |
| 119 | + */ |
| 120 | + public function getImageUploadMaxHeight() |
| 121 | + { |
| 122 | + return $this->imageConfig->getMaxHeight(); |
| 123 | + } |
| 124 | + |
93 | 125 | /** |
94 | 126 | * Prepares layout and set element renderer |
95 | 127 | * |
|
0 commit comments