File tree 2 files changed +2
-21
lines changed
view/frontend/templates/product
2 files changed +2
-21
lines changed Original file line number Diff line number Diff line change 8
8
<view xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:Config/etc/view.xsd" >
9
9
<vars module =" Magento_Catalog" >
10
10
<var name =" product_image_white_borders" >1</var >
11
- <!-- Variable to enable lazy loading for catalog product images without borders.
12
- If you enable this setting your small size images without borders may be stretched in template.
13
- So be sure you have correct image sizes. -->
14
- <var name =" enable_lazy_loading_for_images_without_borders" >0</var >
15
11
</vars >
16
12
</view >
Original file line number Diff line number Diff line change 8
8
/** @var $block \Magento\Catalog\Block\Product\Image */
9
9
/** @var $escaper \Magento\Framework\Escaper */
10
10
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
11
- /**
12
- * Enable lazy loading for images with borders and if variable enable_lazy_loading_for_images_without_borders
13
- * is enabled in view.xml. Otherwise small size images without borders may be distorted. So max-width is used for them
14
- * to prevent stretching and lazy loading does not work.
15
- */
16
- $ borders = (bool )$ block ->getVar ('product_image_white_borders ' , 'Magento_Catalog ' );
17
- $ enableLazyLoadingWithoutBorders = (bool )$ block ->getVar (
18
- 'enable_lazy_loading_for_images_without_borders ' ,
19
- 'Magento_Catalog '
20
- );
21
11
$ width = (int )$ block ->getWidth ();
22
12
$ paddingBottom = $ block ->getRatio () * 100 ;
23
13
?>
@@ -29,13 +19,8 @@ $paddingBottom = $block->getRatio() * 100;
29
19
<?php endforeach ; ?>
30
20
src="<?= $ escaper ->escapeUrl ($ block ->getImageUrl ()) ?> "
31
21
loading="lazy"
32
- <?php if ($ borders || $ enableLazyLoadingWithoutBorders ): ?>
33
- width="<?= $ escaper ->escapeHtmlAttr ($ block ->getWidth ()) ?> "
34
- height="<?= $ escaper ->escapeHtmlAttr ($ block ->getHeight ()) ?> "
35
- <?php else : ?>
36
- max-width="<?= $ escaper ->escapeHtmlAttr ($ block ->getWidth ()) ?> "
37
- max-height="<?= $ escaper ->escapeHtmlAttr ($ block ->getHeight ()) ?> "
38
- <?php endif ; ?>
22
+ width="<?= $ escaper ->escapeHtmlAttr ($ block ->getWidth ()) ?> "
23
+ height="<?= $ escaper ->escapeHtmlAttr ($ block ->getHeight ()) ?> "
39
24
alt="<?= $ escaper ->escapeHtmlAttr ($ block ->getLabel ()) ?> "/></span>
40
25
</span>
41
26
<?php
You can’t perform that action at this time.
0 commit comments