forked from Hevelop/magento2-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Patch-Magento_Catalog-M2.3-issue-19710-wrong-keep-frame-value.patch
87 lines (82 loc) · 3.67 KB
/
Patch-Magento_Catalog-M2.3-issue-19710-wrong-keep-frame-value.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
--- Model/Product/Image/ParamsBuilder.php 2020-04-22 11:03:52.558000000 +0200
+++ Model/Product/Image/ParamsBuilder.php 2020-04-22 11:08:06.468750762 +0200
@@ -11,6 +11,7 @@
use Magento\Framework\View\ConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Catalog\Model\Product\Image;
+use Magento\Theme\Model\Theme;
/**
* Builds parameters array used to build Image Asset
@@ -69,11 +70,12 @@
*
* @param array $imageArguments
* @param int $scopeId
+ * @param Theme $theme
* @return array
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- public function build(array $imageArguments, int $scopeId = null): array
+ public function build(array $imageArguments, int $scopeId = null, Theme $theme = null): array
{
$miscParams = [
'image_type' => $imageArguments['type'] ?? null,
@@ -81,7 +83,7 @@
'image_width' => $imageArguments['width'] ?? null,
];
- $overwritten = $this->overwriteDefaultValues($imageArguments);
+ $overwritten = $this->overwriteDefaultValues($imageArguments, $theme);
$watermark = isset($miscParams['image_type']) ? $this->getWatermark($miscParams['image_type'], $scopeId) : [];
return array_merge($miscParams, $overwritten, $watermark);
@@ -91,26 +93,27 @@
* Overwrite default values
*
* @param array $imageArguments
+ * @param Theme $theme
* @return array
*/
- private function overwriteDefaultValues(array $imageArguments): array
+ private function overwriteDefaultValues(array $imageArguments, Theme $theme = null): array
{
- $frame = $imageArguments['frame'] ?? $this->hasDefaultFrame();
+ $frame = $imageArguments['frame'] ?? $this->hasDefaultFrame($theme);
$constrain = $imageArguments['constrain'] ?? $this->defaultConstrainOnly;
$aspectRatio = $imageArguments['aspect_ratio'] ?? $this->defaultKeepAspectRatio;
$transparency = $imageArguments['transparency'] ?? $this->defaultKeepTransparency;
$background = $imageArguments['background'] ?? $this->defaultBackground;
$angle = $imageArguments['angle'] ?? $this->defaultAngle;
- $quality = (int) $this->scopeConfig->getValue(Image::XML_PATH_JPEG_QUALITY);
+ $quality = (int)$this->scopeConfig->getValue(Image::XML_PATH_JPEG_QUALITY);
return [
- 'background' => (array) $background,
+ 'background' => (array)$background,
'angle' => $angle,
'quality' => $quality,
- 'keep_aspect_ratio' => (bool) $aspectRatio,
- 'keep_frame' => (bool) $frame,
- 'keep_transparency' => (bool) $transparency,
- 'constrain_only' => (bool) $constrain,
+ 'keep_aspect_ratio' => (bool)$aspectRatio,
+ 'keep_frame' => (bool)$frame,
+ 'keep_transparency' => (bool)$transparency,
+ 'constrain_only' => (bool)$constrain,
];
}
@@ -163,11 +166,14 @@
/**
* Get frame from product_image_white_borders
*
+ * @param Theme $theme
* @return bool
*/
- private function hasDefaultFrame(): bool
+ private function hasDefaultFrame(Theme $theme = null): bool
{
- return (bool) $this->viewConfig->getViewConfig(['area' => \Magento\Framework\App\Area::AREA_FRONTEND])
- ->getVarValue('Magento_Catalog', 'product_image_white_borders');
+ return (bool) $this->viewConfig->getViewConfig([
+ 'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
+ 'themeModel' => $theme
+ ])->getVarValue('Magento_Catalog', 'product_image_white_borders');
}
}