From 761bd2498ce76d219c39aa63689ea571e0bdcbea Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Fri, 3 Nov 2017 15:39:41 +0200 Subject: [PATCH] magento/magento2#11888: Save background color correctly in images. --- app/code/Magento/Catalog/Model/ImageExtractor.php | 5 ++++- .../Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ImageExtractor.php b/app/code/Magento/Catalog/Model/ImageExtractor.php index 63e1801195add..7888d8de1c2ff 100644 --- a/app/code/Magento/Catalog/Model/ImageExtractor.php +++ b/app/code/Magento/Catalog/Model/ImageExtractor.php @@ -31,8 +31,11 @@ public function process(\DOMElement $mediaNode, $mediaParentTag) if ($attribute->nodeType != XML_ELEMENT_NODE) { continue; } - if ($attribute->tagName == 'background') { + $attributeTagName = $attribute->tagName; + if ($attributeTagName === 'background') { $nodeValue = $this->processImageBackground($attribute->nodeValue); + } elseif ($attributeTagName === 'width' || $attributeTagName === 'height') { + $nodeValue = intval($attribute->nodeValue); } else { $nodeValue = $attribute->nodeValue; } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php index 05ed780fc1e3d..3b0262aa99e4f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php @@ -23,7 +23,7 @@ protected function setUp() public function testProcess() { $expectedArray = include(__DIR__ . '/_files/converted_view.php'); - $this->assertEquals($expectedArray, $this->model->process($this->getDomElement(), 'media')); + $this->assertSame($expectedArray, $this->model->process($this->getDomElement(), 'media')); } /**