Skip to content

Commit 3f3489d

Browse files
committed
Placeholder fallback. Unescaped output comment.
1 parent a48c087 commit 3f3489d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,19 @@ private function getGalleryImagesConfig()
233233

234234
return $this->getData('gallery_images_config');
235235
}
236+
237+
/**
238+
* @param string $image
239+
* @return string
240+
*/
241+
public function getMainProductImage()
242+
{
243+
$image = $this->getGalleryImages()->toArray()['items'][0]['medium_image_url'];
244+
245+
if (!$image) {
246+
return $this->_imageHelper->getDefaultPlaceholderUrl('image');
247+
}
248+
249+
return $image;
250+
}
236251
}

app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
*/
1414
?>
1515

16-
<?php $images = $block->getGalleryImages()->toArray()['items'] ?>
17-
1816
<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
1917
<img
2018
class="gallery-placeholder__image"
21-
src="<?= $images[0]['medium_image_url'] ?>"
19+
src="<?= /* @escapeNotVerified */ $block->getMainProductImage() ?>"
2220
/>
2321
</div>
2422

0 commit comments

Comments
 (0)