Skip to content

Commit ef57281

Browse files
ENGCOM-6261: Relocate Watermark insert on image after resize. #25514 #25528
- Merge Pull Request #25528 from Krielkip/magento2:bug/25514 - Merged commits: 1. 85415ef 2. 2263d2e
2 parents 3efbe15 + 2263d2e commit ef57281

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

app/code/Magento/Catalog/Model/Product/Image/ParamsBuilder.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@ private function getWatermark(string $type, int $scopeId = null): array
130130
);
131131

132132
if ($file) {
133-
$size = $this->scopeConfig->getValue(
134-
"design/watermark/{$type}_size",
135-
ScopeInterface::SCOPE_STORE,
136-
$scopeId
133+
$size = explode(
134+
'x',
135+
$this->scopeConfig->getValue(
136+
"design/watermark/{$type}_size",
137+
ScopeInterface::SCOPE_STORE
138+
)
137139
);
138140
$opacity = $this->scopeConfig->getValue(
139141
"design/watermark/{$type}_imageOpacity",
@@ -145,8 +147,8 @@ private function getWatermark(string $type, int $scopeId = null): array
145147
ScopeInterface::SCOPE_STORE,
146148
$scopeId
147149
);
148-
$width = !empty($size['width']) ? $size['width'] : null;
149-
$height = !empty($size['height']) ? $size['height'] : null;
150+
$width = !empty($size['0']) ? $size['0'] : null;
151+
$height = !empty($size['1']) ? $size['1'] : null;
150152

151153
return [
152154
'watermark_file' => $file,

app/code/Magento/MediaStorage/Service/ImageResize.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ private function resize(array $imageParams, string $originalImagePath, string $o
311311
]
312312
);
313313

314+
if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) {
315+
$image->resize($imageParams['image_width'], $imageParams['image_height']);
316+
}
317+
314318
if (isset($imageParams['watermark_file'])) {
315319
if ($imageParams['watermark_height'] !== null) {
316320
$image->setWatermarkHeight($imageParams['watermark_height']);
@@ -331,9 +335,6 @@ private function resize(array $imageParams, string $originalImagePath, string $o
331335
$image->watermark($this->getWatermarkFilePath($imageParams['watermark_file']));
332336
}
333337

334-
if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) {
335-
$image->resize($imageParams['image_width'], $imageParams['image_height']);
336-
}
337338
$image->save($imageAsset->getPath());
338339

339340
if ($this->fileStorageDatabase->checkDbUsage()) {

0 commit comments

Comments
 (0)