Skip to content

Commit 1f3fb20

Browse files
ENGCOM-8251: Bugfix/wrong size attributes in image with border #30139
- Merge Pull Request #30139 from GrimLink/magento2:bugfix/wrong-size-attributes-in-image_with_border - Merged commits: 1. 395907d 2. 5092948 3. fe5be17 4. 1adc538 5. 3d609a9 6. 7fd7a68
2 parents ae30d5e + 7fd7a68 commit 1f3fb20

File tree

5 files changed

+5
-26
lines changed

5 files changed

+5
-26
lines changed

app/code/Magento/Catalog/etc/view.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@
88
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
99
<vars module="Magento_Catalog">
1010
<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>
1511
</vars>
1612
</view>

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88
/** @var $block \Magento\Catalog\Block\Product\Image */
99
/** @var $escaper \Magento\Framework\Escaper */
1010
/** @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-
);
2111
$width = (int)$block->getWidth();
2212
$paddingBottom = $block->getRatio() * 100;
2313
?>
@@ -29,13 +19,8 @@ $paddingBottom = $block->getRatio() * 100;
2919
<?php endforeach; ?>
3020
src="<?= $escaper->escapeUrl($block->getImageUrl()) ?>"
3121
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()) ?>"
3924
alt="<?= $escaper->escapeHtmlAttr($block->getLabel()) ?>"/></span>
4025
</span>
4126
<?php

app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,12 @@
117117
.product-image-photo {
118118
bottom: 0;
119119
display: block;
120-
height: auto;
121120
left: 0;
122121
margin: auto;
123-
max-width: 100%;
124122
position: absolute;
125123
right: 0;
126124
top: 0;
125+
width: auto;
127126
}
128127

129128
//

app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,12 @@
9898
.product-image-photo {
9999
bottom: 0;
100100
display: block;
101-
height: auto;
102101
left: 0;
103102
margin: auto;
104-
max-width: 100%;
105103
position: absolute;
106104
right: 0;
107105
top: 0;
106+
width: auto;
108107
}
109108

110109
//

app/design/frontend/Magento/luma/web/css/critical.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)