Skip to content

Commit

Permalink
MAGETWO-69436: Revert Image Resize Improvements from 2.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
vzabaznov committed May 24, 2017
1 parent a2f2893 commit d6e58bf
Show file tree
Hide file tree
Showing 33 changed files with 332 additions and 2,153 deletions.
14 changes: 2 additions & 12 deletions app/code/Magento/Catalog/Block/Product/AbstractProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/
namespace Magento\Catalog\Block\Product;

use Magento\Framework\App\ObjectManager;

/**
* Class AbstractProduct
* @SuppressWarnings(PHPMD.NumberOfChildren)
Expand Down Expand Up @@ -99,13 +97,9 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template
/**
* @param Context $context
* @param array $data
* @param ImageBlockBuilder|null $imageBlockBuilder
*/
public function __construct(
Context $context,
array $data = [],
ImageBlockBuilder $imageBlockBuilder = null
) {
public function __construct(\Magento\Catalog\Block\Product\Context $context, array $data = [])
{
$this->_imageHelper = $context->getImageHelper();
$this->imageBuilder = $context->getImageBuilder();
$this->_compareProduct = $context->getCompareProduct();
Expand All @@ -117,10 +111,6 @@ public function __construct(
$this->_mathRandom = $context->getMathRandom();
$this->reviewRenderer = $context->getReviewRenderer();
$this->stockRegistry = $context->getStockRegistry();
$this->assign(
'imageBlockBuilder',
$imageBlockBuilder ?: ObjectManager::getInstance()->get(ImageBlockBuilder::class)
);
parent::__construct($context, $data);
}

Expand Down
157 changes: 0 additions & 157 deletions app/code/Magento/Catalog/Block/Product/ImageBlockBuilder.php

This file was deleted.

6 changes: 4 additions & 2 deletions app/code/Magento/Catalog/Block/Product/View/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ public function getGalleryImages()
);
$image->setData(
'medium_image_url',
$this->_imageHelper->init($product, 'product_page_image_medium_no_frame')
$this->_imageHelper->init($product, 'product_page_image_medium')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'large_image_url',
$this->_imageHelper->init($product, 'product_page_image_large_no_frame')
$this->_imageHelper->init($product, 'product_page_image_large')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
Expand Down
22 changes: 14 additions & 8 deletions app/code/Magento/Catalog/Helper/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,15 @@ public function init($product, $imageId, $attributes = [])
protected function setImageProperties()
{
$this->_getModel()->setDestinationSubdir($this->getType());

$this->_getModel()->setWidth($this->getWidth());
$this->_getModel()->setHeight($this->getHeight());

// Set 'keep frame' flag
$frame = $this->getFrame();
$this->_getModel()->setKeepFrame($frame);
if (!empty($frame)) {
$this->_getModel()->setKeepFrame($frame);
}

// Set 'constrain only' flag
$constrain = $this->getAttribute('constrain');
Expand Down Expand Up @@ -238,25 +241,25 @@ protected function setWatermarkProperties()
{
$this->setWatermark(
$this->scopeConfig->getValue(
"design/watermark/{$this->getType()}_image",
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_image",
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
);
$this->setWatermarkImageOpacity(
$this->scopeConfig->getValue(
"design/watermark/{$this->getType()}_imageOpacity",
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity",
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
);
$this->setWatermarkPosition(
$this->scopeConfig->getValue(
"design/watermark/{$this->getType()}_position",
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_position",
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
);
$this->setWatermarkSize(
$this->scopeConfig->getValue(
"design/watermark/{$this->getType()}_size",
"design/watermark/{$this->_getModel()->getDestinationSubdir()}_size",
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
);
Expand Down Expand Up @@ -494,7 +497,10 @@ protected function initBaseFile()
protected function isScheduledActionsAllowed()
{
$model = $this->_getModel();
if ($model->isBaseFilePlaceholder() || $model->isCached()) {
if ($model->isBaseFilePlaceholder()
&& $model->getNewFile() === true
|| $model->isCached()
) {
return false;
}
return true;
Expand Down Expand Up @@ -823,10 +829,10 @@ public function getHeight()
public function getFrame()
{
$frame = $this->getAttribute('frame');
if ($frame === null) {
if (empty($frame)) {
$frame = $this->getConfigView()->getVarValue('Magento_Catalog', 'product_image_white_borders');
}
return (bool)$frame;
return $frame;
}

/**
Expand Down
Loading

0 comments on commit d6e58bf

Please sign in to comment.