Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit ecebc42

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - magento/magento2#17602: Fix Custom Attribute Group can not translate in catalog/product page (by @GraysonChiang) - magento/magento2#15942: Making configurable settings for MAX_IMAGE_WIDTH and MAX_IMAGE_HEIGHT (by @eduard13) Fixed GitHub Issues: - magento/magento2#13747: Wysiwyg > Image Uploader >Max width/height (reported by @Detzler) has been fixed in magento/magento2#15942 by @eduard13 in 2.2-develop branch Related commits: 1. 933e496 2. a579bff 3. 4ecce14 4. c51b1d4 5. 1d5e56b 6. f7b4a66 7. e1591e4 8. 0c8221b 9. 2491b51 10. 7b4b32f 11. 0f63017 12. 128724f 13. 30822ef 14. 2e69236 15. 614570f 16. 507d183
2 parents 3559460 + 596a8e6 commit ecebc42

File tree

11 files changed

+115
-9
lines changed

11 files changed

+115
-9
lines changed

app/code/Magento/Backend/Block/Media/Uploader.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Backend\Block\Media;
79

810
use Magento\Framework\App\ObjectManager;
911
use Magento\Framework\Serialize\Serializer\Json;
12+
use Magento\Framework\Image\Adapter\ConfigInterface;
1013

1114
/**
1215
* Adminhtml media library uploader
@@ -35,20 +38,29 @@ class Uploader extends \Magento\Backend\Block\Widget
3538
*/
3639
private $jsonEncoder;
3740

41+
/**
42+
* @var ConfigInterface
43+
*/
44+
private $imageConfig;
45+
3846
/**
3947
* @param \Magento\Backend\Block\Template\Context $context
4048
* @param \Magento\Framework\File\Size $fileSize
4149
* @param array $data
4250
* @param Json $jsonEncoder
51+
* @param ConfigInterface $imageConfig
4352
*/
4453
public function __construct(
4554
\Magento\Backend\Block\Template\Context $context,
4655
\Magento\Framework\File\Size $fileSize,
4756
array $data = [],
48-
Json $jsonEncoder = null
57+
Json $jsonEncoder = null,
58+
ConfigInterface $imageConfig = null
4959
) {
5060
$this->_fileSizeService = $fileSize;
5161
$this->jsonEncoder = $jsonEncoder ?: ObjectManager::getInstance()->get(Json::class);
62+
$this->imageConfig = $imageConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class);
63+
5264
parent::__construct($context, $data);
5365
}
5466

@@ -90,6 +102,26 @@ public function getFileSizeService()
90102
return $this->_fileSizeService;
91103
}
92104

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+
93125
/**
94126
* Prepares layout and set element renderer
95127
*

app/code/Magento/Backend/etc/adminhtml/system.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,19 @@
319319
</depends>
320320
</field>
321321
</group>
322+
<group id="upload_configuration" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="1">
323+
<label>Images Upload Configuration</label>
324+
<field id="max_width" translate="label comment" type="text" sortOrder="100" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
325+
<label>Maximum Width</label>
326+
<validate>validate-greater-than-zero validate-number required-entry</validate>
327+
<comment>Maximum allowed width for uploaded image.</comment>
328+
</field>
329+
<field id="max_height" translate="label comment" type="text" sortOrder="200" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
330+
<label>Maximum Height</label>
331+
<validate>validate-greater-than-zero validate-number required-entry</validate>
332+
<comment>Maximum allowed height for uploaded image.</comment>
333+
</field>
334+
</group>
322335
</section>
323336
<section id="admin" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
324337
<label>Admin</label>

app/code/Magento/Backend/etc/config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
<dashboard>
2929
<enable_charts>1</enable_charts>
3030
</dashboard>
31+
<upload_configuration>
32+
<max_width>1920</max_width>
33+
<max_height>1200</max_height>
34+
</upload_configuration>
3135
</system>
3236
<general>
3337
<validator_data>

app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
data-mage-init='{
1414
"Magento_Backend/js/media-uploader" : {
1515
"maxFileSize": <?= /* @escapeNotVerified */ $block->getFileSizeService()->getMaxFileSize() ?>,
16-
"maxWidth":<?= /* @escapeNotVerified */ \Magento\Framework\File\Uploader::MAX_IMAGE_WIDTH ?> ,
17-
"maxHeight": <?= /* @escapeNotVerified */ \Magento\Framework\File\Uploader::MAX_IMAGE_HEIGHT ?>
16+
"maxWidth":<?= /* @escapeNotVerified */ $block->getImageUploadMaxWidth() ?> ,
17+
"maxHeight": <?= /* @escapeNotVerified */ $block->getImageUploadMaxHeight() ?>
1818
}
1919
}'
2020
>

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function modifyMeta(array $meta)
282282
if ($attributes) {
283283
$meta[$groupCode]['children'] = $this->getAttributesMeta($attributes, $groupCode);
284284
$meta[$groupCode]['arguments']['data']['config']['componentType'] = Fieldset::NAME;
285-
$meta[$groupCode]['arguments']['data']['config']['label'] = __('%1', $group->getAttributeGroupName());
285+
$meta[$groupCode]['arguments']['data']['config']['label'] = __($group->getAttributeGroupName());
286286
$meta[$groupCode]['arguments']['data']['config']['collapsible'] = true;
287287
$meta[$groupCode]['arguments']['data']['config']['dataScope'] = self::DATA_SCOPE_PRODUCT;
288288
$meta[$groupCode]['arguments']['data']['config']['sortOrder'] =

app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Uploader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content;
79

810
/**

app/code/Magento/Cms/view/adminhtml/templates/browser/content/uploader.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ require([
101101
maxFileSize: <?= (int) $block->getFileSizeService()->getMaxFileSize() ?> * 10
102102
}, {
103103
action: 'resize',
104-
maxWidth: <?= (float) \Magento\Framework\File\Uploader::MAX_IMAGE_WIDTH ?> ,
105-
maxHeight: <?= (float) \Magento\Framework\File\Uploader::MAX_IMAGE_HEIGHT ?>
104+
maxWidth: <?= (int) $block->getImageUploadMaxWidth() ?> ,
105+
maxHeight: <?= (int) $block->getImageUploadMaxHeight() ?>
106106
}, {
107107
action: 'save'
108108
}]

app/code/Magento/Theme/Block/Adminhtml/Wysiwyg/Files/Content/Uploader.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Theme\Block\Adminhtml\Wysiwyg\Files\Content;
79

810
/**
@@ -39,6 +41,7 @@ public function __construct(
3941
array $data = []
4042
) {
4143
$this->_storageHelper = $storageHelper;
44+
4245
parent::__construct($context, $fileSize, $data);
4346
}
4447

lib/internal/Magento/Framework/File/Uploader.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Framework\File;
77

8+
use Magento\Framework\Image\Adapter\UploadConfigInterface;
9+
810
/**
911
* File upload class
1012
*
@@ -136,12 +138,16 @@ class Uploader
136138
const TMP_NAME_EMPTY = 666;
137139

138140
/**
139-
* Max Image Width resolution in pixels. For image resizing on client side
141+
* Maximum Image Width resolution in pixels. For image resizing on client side
142+
* @deprecated
143+
* @see UploadConfigInterface::getMaxWidth()
140144
*/
141145
const MAX_IMAGE_WIDTH = 1920;
142146

143147
/**
144-
* Max Image Height resolution in pixels. For image resizing on client side
148+
* Maximum Image Height resolution in pixels. For image resizing on client side
149+
* @deprecated
150+
* @see UploadConfigInterface::getMaxHeight()
145151
*/
146152
const MAX_IMAGE_HEIGHT = 1200;
147153

lib/internal/Magento/Framework/Image/Adapter/Config.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
*/
66
namespace Magento\Framework\Image\Adapter;
77

8-
class Config implements \Magento\Framework\Image\Adapter\ConfigInterface
8+
class Config implements ConfigInterface, UploadConfigInterface
99
{
1010
const XML_PATH_IMAGE_ADAPTER = 'dev/image/default_adapter';
1111

1212
const XML_PATH_IMAGE_ADAPTERS = 'dev/image/adapters';
1313

14+
const XML_PATH_MAX_WIDTH_IMAGE = 'system/upload_configuration/max_width';
15+
16+
const XML_PATH_MAX_HEIGHT_IMAGE = 'system/upload_configuration/max_height';
17+
1418
/**
1519
* @var \Magento\Framework\App\Config\ScopeConfigInterface
1620
*/
@@ -43,4 +47,24 @@ public function getAdapters()
4347
{
4448
return $this->config->getValue(self::XML_PATH_IMAGE_ADAPTERS);
4549
}
50+
51+
/**
52+
* Get Maximum Image Width resolution in pixels. For image resizing on client side
53+
*
54+
* @return int
55+
*/
56+
public function getMaxWidth()
57+
{
58+
return $this->config->getValue(self::XML_PATH_MAX_WIDTH_IMAGE);
59+
}
60+
61+
/**
62+
* Get Maximum Image Height resolution in pixels. For image resizing on client side
63+
*
64+
* @return int
65+
*/
66+
public function getMaxHeight()
67+
{
68+
return $this->config->getValue(self::XML_PATH_MAX_HEIGHT_IMAGE);
69+
}
4670
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\Image\Adapter;
7+
8+
/**
9+
* Interface UploadConfigInterface
10+
*/
11+
interface UploadConfigInterface
12+
{
13+
/**
14+
* @return int
15+
*/
16+
public function getMaxWidth();
17+
18+
/**
19+
* @return int
20+
*/
21+
public function getMaxHeight();
22+
}

0 commit comments

Comments
 (0)