Skip to content

Commit c8f78ff

Browse files
authored
Check null value in getStringCustomAttributes()
If $attributes value is null, we convert to empty array to prevent that loop causes Exception.
1 parent 777c9a9 commit c8f78ff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/code/Magento/Catalog/Block/Product/ImageFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function __construct(
7676
private function getStringCustomAttributes(array $attributes): string
7777
{
7878
$result = [];
79+
$attributes = (is_null($attributes)) ? [] : $attributes;
7980
foreach ($attributes as $name => $value) {
8081
if ($name != 'class') {
8182
$result[] = $name . '="' . $value . '"';
@@ -131,10 +132,10 @@ private function getLabel(Product $product, string $imageType): string
131132
*
132133
* @param Product $product
133134
* @param string $imageId
134-
* @param array $attributes
135+
* @param array|null $attributes
135136
* @return ImageBlock
136137
*/
137-
public function create(Product $product, string $imageId, array $attributes = []): ImageBlock
138+
public function create(Product $product, string $imageId, array $attributes = null): ImageBlock
138139
{
139140
$viewImageConfig = $this->presentationConfig->getViewConfig()->getMediaAttributes(
140141
'Magento_Catalog',

0 commit comments

Comments
 (0)