Skip to content

Commit d00b6f2

Browse files
committed
fix Categoy image plugin PHP 8.4 CS
1 parent 9bcd51c commit d00b6f2

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

Core/Image/Transformation.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public function __construct()
3131

3232
public function withDefaultImage(DefaultImage $defaultImage)
3333
{
34-
$this->defaultImage = trim((string)$defaultImage);
34+
$defaultImageStr = trim((string)$defaultImage);
35+
if (!empty($defaultImageStr)) {
36+
$this->defaultImage = $defaultImageStr;
37+
}
3538
return $this;
3639
}
3740

@@ -102,7 +105,7 @@ public function build()
102105
'height' => $this->dimensions ? $this->dimensions->getHeight() : null,
103106
'dpr' => (string)$this->dpr,
104107
'flags' => $this->flags,
105-
'default_image' => $this->defaultImage,
108+
'default_image' => $this->defaultImage ?? '',
106109
]
107110
];
108111
}

Plugin/Catalog/Block/Category/Image.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Cloudinary\Configuration\Configuration;
1111
use Magento\Framework\View\Element\Block\ArgumentInterface;
1212
use Magento\Catalog\Model\Category;
13+
use Cloudinary\Cloudinary\Core\Image as CoreImage;
1314

1415
class Image
1516
{
@@ -58,12 +59,16 @@ public function afterGetUrl(
5859
$filename = pathinfo($imagePath, PATHINFO_FILENAME);
5960
$publicId = preg_replace('/^cld_[a-f0-9]+_/', '', $filename);
6061

61-
return Media::fromParams($publicId, [
62+
$asset = Media::fromParams($publicId, [
6263
'transformation' => $this->transformation->build(),
6364
'secure' => true,
6465
'sign_url' => $this->configuration->getUseSignedUrls(),
6566
'version' => 1
66-
]);
67+
]) . '?_i=AB';
68+
69+
$image = CoreImage::fromPath($asset, '');
70+
return (string) $image;
71+
6772
} catch (\Exception $e) {
6873
return $result; // fallback to original if Cloudinary fails
6974
}

0 commit comments

Comments
 (0)