File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \Catalog \Model ;
7
7
8
- use Magento \Catalog \Model \Product \Attribute \Backend \Media \ImageEntryConverter ;
9
8
use Magento \Catalog \Helper \Image ;
9
+ use Magento \Catalog \Model \Product \Attribute \Backend \Media \ImageEntryConverter ;
10
+ use Magento \Framework \View \Xsd \Media \TypeDataExtractorInterface ;
10
11
11
- class ImageExtractor implements \ Magento \ Framework \ View \ Xsd \ Media \ TypeDataExtractorInterface
12
+ class ImageExtractor implements TypeDataExtractorInterface
12
13
{
13
14
/**
14
15
* Extract configuration data of images from the DOM structure
@@ -30,8 +31,11 @@ public function process(\DOMElement $mediaNode, $mediaParentTag)
30
31
if ($ attribute ->nodeType != XML_ELEMENT_NODE ) {
31
32
continue ;
32
33
}
33
- if ($ attribute ->tagName == 'background ' ) {
34
+ $ attributeTagName = $ attribute ->tagName ;
35
+ if ($ attributeTagName === 'background ' ) {
34
36
$ nodeValue = $ this ->processImageBackground ($ attribute ->nodeValue );
37
+ } elseif ($ attributeTagName === 'width ' || $ attributeTagName === 'height ' ) {
38
+ $ nodeValue = intval ($ attribute ->nodeValue );
35
39
} else {
36
40
$ nodeValue = $ attribute ->nodeValue ;
37
41
}
@@ -55,6 +59,7 @@ private function processImageBackground($backgroundString)
55
59
$ backgroundArray = [];
56
60
if (preg_match ($ pattern , $ backgroundString , $ backgroundArray )) {
57
61
array_shift ($ backgroundArray );
62
+ $ backgroundArray = array_map ('intval ' , $ backgroundArray );
58
63
}
59
64
return $ backgroundArray ;
60
65
}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ protected function setUp()
23
23
public function testProcess ()
24
24
{
25
25
$ expectedArray = include (__DIR__ . '/_files/converted_view.php ' );
26
- $ this ->assertEquals ($ expectedArray , $ this ->model ->process ($ this ->getDomElement (), 'media ' ));
26
+ $ this ->assertSame ($ expectedArray , $ this ->model ->process ($ this ->getDomElement (), 'media ' ));
27
27
}
28
28
29
29
/**
You can’t perform that action at this time.
0 commit comments