File tree Expand file tree Collapse file tree 3 files changed +28
-29
lines changed
view/frontend/templates/product/view Expand file tree Collapse file tree 3 files changed +28
-29
lines changed Original file line number Diff line number Diff line change @@ -239,4 +239,23 @@ private function getGalleryImagesConfig()
239
239
240
240
return $ this ->getData ('gallery_images_config ' );
241
241
}
242
+
243
+ /**
244
+ * Get main product image
245
+ *
246
+ * @param string $size
247
+ * @return string
248
+ */
249
+ public function getMainProductImage ($ size = 'medium_image_url ' )
250
+ {
251
+ foreach ($ this ->getGalleryImages () as $ image ) {
252
+ $ image = $ image ->getData ($ size );
253
+
254
+ if (!$ image ) {
255
+ return $ this ->_imageHelper ->getDefaultPlaceholderUrl ('image ' );
256
+ }
257
+
258
+ return $ image ;
259
+ }
260
+ }
242
261
}
Original file line number Diff line number Diff line change 12
12
* @var $block \Magento\Catalog\Block\Product\View\Gallery
13
13
*/
14
14
?>
15
+
15
16
<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
16
- <div data-role="loader" class="loading-mask">
17
- <div class="loader">
18
- <img src="<?= /* @escapeNotVerified */ $ block ->getViewFileUrl ('images/loader-1.gif ' ) ?> "
19
- alt="<?= /* @escapeNotVerified */ __ ('Loading... ' ) ?> ">
20
- </div>
21
- </div>
17
+ <img
18
+ class="gallery-placeholder__image"
19
+ src="<?= /* @escapeNotVerified */ $ block ->getMainProductImage () ?> "
20
+ />
22
21
</div>
23
- <!--Fix for jumping content. Loader must be the same size as gallery.-->
24
- <script>
25
- var config = {
26
- "width": <?= /* @escapeNotVerified */ $ block ->getImageAttribute ('product_page_image_medium ' , 'width ' ) ?> ,
27
- "thumbheight": <?php /* @escapeNotVerified */ echo $ block ->getImageAttribute ('product_page_image_small ' , 'height ' )
28
- ?: $ block ->getImageAttribute ('product_page_image_small ' , 'width ' ); ?> ,
29
- "navtype": "<?= /* @escapeNotVerified */ $ block ->getVar ("gallery/navtype " ) ?> ",
30
- "height": <?= /* @escapeNotVerified */ $ block ->getImageAttribute ('product_page_image_medium ' , 'height ' ) ?>
31
- },
32
- thumbBarHeight = 0,
33
- loader = document.querySelectorAll('[data-gallery-role="gallery-placeholder"] [data-role="loader"]')[0];
34
22
35
- if (config.navtype === 'horizontal') {
36
- thumbBarHeight = config.thumbheight;
37
- }
38
-
39
- loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
40
- </script>
41
23
<script type="text/x-magento-init">
42
24
{
43
25
"[data-gallery-role=gallery-placeholder]": {
Original file line number Diff line number Diff line change 977
977
978
978
// While first time init
979
979
.gallery-placeholder {
980
- .loading-mask {
981
- padding : 0 0 50% ;
982
- position : static ;
983
- }
984
- .loader img {
985
- position : absolute ;
980
+ &__image {
981
+ display : block ;
982
+ margin : auto ;
986
983
}
987
984
}
988
985
1003
1000
display : block ;
1004
1001
}
1005
1002
}
1003
+
1006
1004
.fotorama__product-video--loaded {
1007
1005
.fotorama__img , .fotorama__img--full {
1008
1006
display : none !important ;
You can’t perform that action at this time.
0 commit comments