Skip to content

Commit 5ca9e13

Browse files
committed
Merge remote-tracking branch 'gallery/feature/fotorama-speedup' into MC-15440
2 parents 62ae101 + d128271 commit 5ca9e13

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,23 @@ private function getGalleryImagesConfig()
239239

240240
return $this->getData('gallery_images_config');
241241
}
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+
}
242261
}

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,14 @@
1212
* @var $block \Magento\Catalog\Block\Product\View\Gallery
1313
*/
1414
?>
15+
1516
<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+
/>
2221
</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];
3422

35-
if (config.navtype === 'horizontal') {
36-
thumbBarHeight = config.thumbheight;
37-
}
38-
39-
loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
40-
</script>
4123
<script type="text/x-magento-init">
4224
{
4325
"[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
@@ -977,12 +977,9 @@
977977

978978
// While first time init
979979
.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;
986983
}
987984
}
988985

@@ -1003,6 +1000,7 @@
10031000
display: block;
10041001
}
10051002
}
1003+
10061004
.fotorama__product-video--loaded {
10071005
.fotorama__img, .fotorama__img--full {
10081006
display: none !important;

0 commit comments

Comments
 (0)