Skip to content

Commit d6e58bf

Browse files
committed
MAGETWO-69436: Revert Image Resize Improvements from 2.1.7
1 parent a2f2893 commit d6e58bf

File tree

33 files changed

+332
-2153
lines changed

33 files changed

+332
-2153
lines changed

app/code/Magento/Catalog/Block/Product/AbstractProduct.php

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

8-
use Magento\Framework\App\ObjectManager;
9-
108
/**
119
* Class AbstractProduct
1210
* @SuppressWarnings(PHPMD.NumberOfChildren)
@@ -99,13 +97,9 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template
9997
/**
10098
* @param Context $context
10199
* @param array $data
102-
* @param ImageBlockBuilder|null $imageBlockBuilder
103100
*/
104-
public function __construct(
105-
Context $context,
106-
array $data = [],
107-
ImageBlockBuilder $imageBlockBuilder = null
108-
) {
101+
public function __construct(\Magento\Catalog\Block\Product\Context $context, array $data = [])
102+
{
109103
$this->_imageHelper = $context->getImageHelper();
110104
$this->imageBuilder = $context->getImageBuilder();
111105
$this->_compareProduct = $context->getCompareProduct();
@@ -117,10 +111,6 @@ public function __construct(
117111
$this->_mathRandom = $context->getMathRandom();
118112
$this->reviewRenderer = $context->getReviewRenderer();
119113
$this->stockRegistry = $context->getStockRegistry();
120-
$this->assign(
121-
'imageBlockBuilder',
122-
$imageBlockBuilder ?: ObjectManager::getInstance()->get(ImageBlockBuilder::class)
123-
);
124114
parent::__construct($context, $data);
125115
}
126116

app/code/Magento/Catalog/Block/Product/ImageBlockBuilder.php

Lines changed: 0 additions & 157 deletions
This file was deleted.

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ public function getGalleryImages()
6363
);
6464
$image->setData(
6565
'medium_image_url',
66-
$this->_imageHelper->init($product, 'product_page_image_medium_no_frame')
66+
$this->_imageHelper->init($product, 'product_page_image_medium')
67+
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
6768
->setImageFile($image->getFile())
6869
->getUrl()
6970
);
7071
$image->setData(
7172
'large_image_url',
72-
$this->_imageHelper->init($product, 'product_page_image_large_no_frame')
73+
$this->_imageHelper->init($product, 'product_page_image_large')
74+
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
7375
->setImageFile($image->getFile())
7476
->getUrl()
7577
);

app/code/Magento/Catalog/Helper/Image.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,15 @@ public function init($product, $imageId, $attributes = [])
195195
protected function setImageProperties()
196196
{
197197
$this->_getModel()->setDestinationSubdir($this->getType());
198+
198199
$this->_getModel()->setWidth($this->getWidth());
199200
$this->_getModel()->setHeight($this->getHeight());
200201

201202
// Set 'keep frame' flag
202203
$frame = $this->getFrame();
203-
$this->_getModel()->setKeepFrame($frame);
204+
if (!empty($frame)) {
205+
$this->_getModel()->setKeepFrame($frame);
206+
}
204207

205208
// Set 'constrain only' flag
206209
$constrain = $this->getAttribute('constrain');
@@ -238,25 +241,25 @@ protected function setWatermarkProperties()
238241
{
239242
$this->setWatermark(
240243
$this->scopeConfig->getValue(
241-
"design/watermark/{$this->getType()}_image",
244+
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_image",
242245
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
243246
)
244247
);
245248
$this->setWatermarkImageOpacity(
246249
$this->scopeConfig->getValue(
247-
"design/watermark/{$this->getType()}_imageOpacity",
250+
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity",
248251
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
249252
)
250253
);
251254
$this->setWatermarkPosition(
252255
$this->scopeConfig->getValue(
253-
"design/watermark/{$this->getType()}_position",
256+
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_position",
254257
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
255258
)
256259
);
257260
$this->setWatermarkSize(
258261
$this->scopeConfig->getValue(
259-
"design/watermark/{$this->getType()}_size",
262+
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_size",
260263
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
261264
)
262265
);
@@ -494,7 +497,10 @@ protected function initBaseFile()
494497
protected function isScheduledActionsAllowed()
495498
{
496499
$model = $this->_getModel();
497-
if ($model->isBaseFilePlaceholder() || $model->isCached()) {
500+
if ($model->isBaseFilePlaceholder()
501+
&& $model->getNewFile() === true
502+
|| $model->isCached()
503+
) {
498504
return false;
499505
}
500506
return true;
@@ -823,10 +829,10 @@ public function getHeight()
823829
public function getFrame()
824830
{
825831
$frame = $this->getAttribute('frame');
826-
if ($frame === null) {
832+
if (empty($frame)) {
827833
$frame = $this->getConfigView()->getVarValue('Magento_Catalog', 'product_image_white_borders');
828834
}
829-
return (bool)$frame;
835+
return $frame;
830836
}
831837

832838
/**

0 commit comments

Comments
 (0)