Skip to content

Commit 2f86082

Browse files
committed
MC-23383: Introduce image lazy loading mechanism
- Move comment from html to php;
1 parent afbbc74 commit 2f86082

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<?php
88
/** @var $block \Magento\Catalog\Block\Product\Image */
99
/** @var $escaper \Magento\Framework\Escaper */
10+
/**
11+
* Enable lazy loading for images with borders and if variable enable_lazy_loading_for_images_without_borders
12+
* is enabled in view.xml. Otherwise small size images without borders may be distorted. So max-width is used for them
13+
* to prevent stretching and lazy loading does not work.
14+
*/
1015
$borders = (bool)$block->getVar('product_image_white_borders', 'Magento_Catalog');
1116
$enableLazyLoadingWithoutBorders = (bool)$block->getVar(
1217
'enable_lazy_loading_for_images_without_borders',
@@ -24,8 +29,6 @@ $enableLazyLoadingWithoutBorders = (bool)$block->getVar(
2429
<?php endforeach; ?>
2530
src="<?= $escaper->escapeUrl($block->getImageUrl()) ?>"
2631
loading="lazy"
27-
<!-- Enable lazy loading for images with borders and if variable
28-
enable_lazy_loading_for_images_without_borders in view.xml is enabled -->
2932
<?php if ($borders || $enableLazyLoadingWithoutBorders): ?>
3033
width="<?= $escaper->escapeHtmlAttr($block->getWidth()) ?>"
3134
height="<?= $escaper->escapeHtmlAttr($block->getHeight()) ?>"

0 commit comments

Comments
 (0)