Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.2-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - magento#17602: Fix Custom Attribute Group can not translate in catalog/product page (by @GraysonChiang)
 - magento#15942: Making configurable settings for MAX_IMAGE_WIDTH and MAX_IMAGE_HEIGHT (by @eduard13)


Fixed GitHub Issues:
 - magento#13747: Wysiwyg > Image Uploader >Max width/height (reported by @Detzler) has been fixed in magento#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
  • Loading branch information
magento-engcom-team authored Aug 16, 2018
2 parents 3559460 + 596a8e6 commit ecebc42
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 9 deletions.
34 changes: 33 additions & 1 deletion app/code/Magento/Backend/Block/Media/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backend\Block\Media;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\Image\Adapter\ConfigInterface;

/**
* Adminhtml media library uploader
Expand Down Expand Up @@ -35,20 +38,29 @@ class Uploader extends \Magento\Backend\Block\Widget
*/
private $jsonEncoder;

/**
* @var ConfigInterface
*/
private $imageConfig;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\File\Size $fileSize
* @param array $data
* @param Json $jsonEncoder
* @param ConfigInterface $imageConfig
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\File\Size $fileSize,
array $data = [],
Json $jsonEncoder = null
Json $jsonEncoder = null,
ConfigInterface $imageConfig = null
) {
$this->_fileSizeService = $fileSize;
$this->jsonEncoder = $jsonEncoder ?: ObjectManager::getInstance()->get(Json::class);
$this->imageConfig = $imageConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class);

parent::__construct($context, $data);
}

Expand Down Expand Up @@ -90,6 +102,26 @@ public function getFileSizeService()
return $this->_fileSizeService;
}

/**
* Get Image Upload Maximum Width Config
*
* @return int
*/
public function getImageUploadMaxWidth()
{
return $this->imageConfig->getMaxWidth();
}

/**
* Get Image Upload Maximum Height Config
*
* @return int
*/
public function getImageUploadMaxHeight()
{
return $this->imageConfig->getMaxHeight();
}

/**
* Prepares layout and set element renderer
*
Expand Down
13 changes: 13 additions & 0 deletions app/code/Magento/Backend/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,19 @@
</depends>
</field>
</group>
<group id="upload_configuration" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Images Upload Configuration</label>
<field id="max_width" translate="label comment" type="text" sortOrder="100" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Maximum Width</label>
<validate>validate-greater-than-zero validate-number required-entry</validate>
<comment>Maximum allowed width for uploaded image.</comment>
</field>
<field id="max_height" translate="label comment" type="text" sortOrder="200" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Maximum Height</label>
<validate>validate-greater-than-zero validate-number required-entry</validate>
<comment>Maximum allowed height for uploaded image.</comment>
</field>
</group>
</section>
<section id="admin" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Admin</label>
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Backend/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<dashboard>
<enable_charts>1</enable_charts>
</dashboard>
<upload_configuration>
<max_width>1920</max_width>
<max_height>1200</max_height>
</upload_configuration>
</system>
<general>
<validator_data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
data-mage-init='{
"Magento_Backend/js/media-uploader" : {
"maxFileSize": <?= /* @escapeNotVerified */ $block->getFileSizeService()->getMaxFileSize() ?>,
"maxWidth":<?= /* @escapeNotVerified */ \Magento\Framework\File\Uploader::MAX_IMAGE_WIDTH ?> ,
"maxHeight": <?= /* @escapeNotVerified */ \Magento\Framework\File\Uploader::MAX_IMAGE_HEIGHT ?>
"maxWidth":<?= /* @escapeNotVerified */ $block->getImageUploadMaxWidth() ?> ,
"maxHeight": <?= /* @escapeNotVerified */ $block->getImageUploadMaxHeight() ?>
}
}'
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function modifyMeta(array $meta)
if ($attributes) {
$meta[$groupCode]['children'] = $this->getAttributesMeta($attributes, $groupCode);
$meta[$groupCode]['arguments']['data']['config']['componentType'] = Fieldset::NAME;
$meta[$groupCode]['arguments']['data']['config']['label'] = __('%1', $group->getAttributeGroupName());
$meta[$groupCode]['arguments']['data']['config']['label'] = __($group->getAttributeGroupName());
$meta[$groupCode]['arguments']['data']['config']['collapsible'] = true;
$meta[$groupCode]['arguments']['data']['config']['dataScope'] = self::DATA_SCOPE_PRODUCT;
$meta[$groupCode]['arguments']['data']['config']['sortOrder'] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ require([
maxFileSize: <?= (int) $block->getFileSizeService()->getMaxFileSize() ?> * 10
}, {
action: 'resize',
maxWidth: <?= (float) \Magento\Framework\File\Uploader::MAX_IMAGE_WIDTH ?> ,
maxHeight: <?= (float) \Magento\Framework\File\Uploader::MAX_IMAGE_HEIGHT ?>
maxWidth: <?= (int) $block->getImageUploadMaxWidth() ?> ,
maxHeight: <?= (int) $block->getImageUploadMaxHeight() ?>
}, {
action: 'save'
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Theme\Block\Adminhtml\Wysiwyg\Files\Content;

/**
Expand Down Expand Up @@ -39,6 +41,7 @@ public function __construct(
array $data = []
) {
$this->_storageHelper = $storageHelper;

parent::__construct($context, $fileSize, $data);
}

Expand Down
10 changes: 8 additions & 2 deletions lib/internal/Magento/Framework/File/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Framework\File;

use Magento\Framework\Image\Adapter\UploadConfigInterface;

/**
* File upload class
*
Expand Down Expand Up @@ -136,12 +138,16 @@ class Uploader
const TMP_NAME_EMPTY = 666;

/**
* Max Image Width resolution in pixels. For image resizing on client side
* Maximum Image Width resolution in pixels. For image resizing on client side
* @deprecated
* @see UploadConfigInterface::getMaxWidth()
*/
const MAX_IMAGE_WIDTH = 1920;

/**
* Max Image Height resolution in pixels. For image resizing on client side
* Maximum Image Height resolution in pixels. For image resizing on client side
* @deprecated
* @see UploadConfigInterface::getMaxHeight()
*/
const MAX_IMAGE_HEIGHT = 1200;

Expand Down
26 changes: 25 additions & 1 deletion lib/internal/Magento/Framework/Image/Adapter/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
*/
namespace Magento\Framework\Image\Adapter;

class Config implements \Magento\Framework\Image\Adapter\ConfigInterface
class Config implements ConfigInterface, UploadConfigInterface
{
const XML_PATH_IMAGE_ADAPTER = 'dev/image/default_adapter';

const XML_PATH_IMAGE_ADAPTERS = 'dev/image/adapters';

const XML_PATH_MAX_WIDTH_IMAGE = 'system/upload_configuration/max_width';

const XML_PATH_MAX_HEIGHT_IMAGE = 'system/upload_configuration/max_height';

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
Expand Down Expand Up @@ -43,4 +47,24 @@ public function getAdapters()
{
return $this->config->getValue(self::XML_PATH_IMAGE_ADAPTERS);
}

/**
* Get Maximum Image Width resolution in pixels. For image resizing on client side
*
* @return int
*/
public function getMaxWidth()
{
return $this->config->getValue(self::XML_PATH_MAX_WIDTH_IMAGE);
}

/**
* Get Maximum Image Height resolution in pixels. For image resizing on client side
*
* @return int
*/
public function getMaxHeight()
{
return $this->config->getValue(self::XML_PATH_MAX_HEIGHT_IMAGE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Image\Adapter;

/**
* Interface UploadConfigInterface
*/
interface UploadConfigInterface
{
/**
* @return int
*/
public function getMaxWidth();

/**
* @return int
*/
public function getMaxHeight();
}

0 comments on commit ecebc42

Please sign in to comment.