File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
view/frontend/templates/product/view Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -233,4 +233,19 @@ private function getGalleryImagesConfig()
233
233
234
234
return $ this ->getData ('gallery_images_config ' );
235
235
}
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
+ }
236
251
}
Original file line number Diff line number Diff line change 13
13
*/
14
14
?>
15
15
16
- <?php $ images = $ block ->getGalleryImages ()->toArray ()['items ' ] ?>
17
-
18
16
<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
19
17
<img
20
18
class="gallery-placeholder__image"
21
- src="<?= $ images [ 0 ][ ' medium_image_url ' ] ?> "
19
+ src="<?= /* @escapeNotVerified */ $ block -> getMainProductImage () ?> "
22
20
/>
23
21
</div>
24
22
You can’t perform that action at this time.
0 commit comments