Skip to content

Commit 697f769

Browse files
committed
Pretier PHP code to make world a better place
1 parent 3f3489d commit 697f769

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,18 @@ private function getGalleryImagesConfig()
235235
}
236236

237237
/**
238-
* @param string $image
239238
* @return string
240239
*/
241-
public function getMainProductImage()
240+
public function getMainProductImage($size = 'medium_image_url')
242241
{
243-
$image = $this->getGalleryImages()->toArray()['items'][0]['medium_image_url'];
242+
foreach ($this->getGalleryImages() as $image) {
243+
$image = $image->getData($size);
244244

245-
if (!$image) {
246-
return $this->_imageHelper->getDefaultPlaceholderUrl('image');
247-
}
245+
if (!$image) {
246+
return $this->_imageHelper->getDefaultPlaceholderUrl('image');
247+
}
248248

249-
return $image;
249+
return $image;
250+
}
250251
}
251252
}

0 commit comments

Comments
 (0)