Skip to content

Commit a48c087

Browse files
committed
Loader replaced with actual product photo to visualy speedup loading
1 parent d394949 commit a48c087

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,16 @@
1212
* @var $block \Magento\Catalog\Block\Product\View\Gallery
1313
*/
1414
?>
15+
16+
<?php $images = $block->getGalleryImages()->toArray()['items'] ?>
17+
1518
<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>
19+
<img
20+
class="gallery-placeholder__image"
21+
src="<?= $images[0]['medium_image_url'] ?>"
22+
/>
2223
</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];
3424

35-
if (config.navtype === 'horizontal') {
36-
thumbBarHeight = config.thumbheight;
37-
}
38-
39-
loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
40-
</script>
4125
<script type="text/x-magento-init">
4226
{
4327
"[data-gallery-role=gallery-placeholder]": {

lib/web/mage/gallery/gallery.less

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -976,12 +976,9 @@
976976

977977
// While first time init
978978
.gallery-placeholder {
979-
.loading-mask {
980-
padding: 0 0 50%;
981-
position: static;
982-
}
983-
.loader img {
984-
position: absolute;
979+
&__image {
980+
display: block;
981+
margin: auto;
985982
}
986983
}
987984

@@ -1002,6 +999,7 @@
1002999
display: block;
10031000
}
10041001
}
1002+
10051003
.fotorama__product-video--loaded {
10061004
.fotorama__img, .fotorama__img--full {
10071005
display: none !important;

0 commit comments

Comments
 (0)