Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
$width = (int)$block->getWidth();
$height = (int)$block->getHeight();
$paddingBottom = $block->getRatio() * 100;

if (!isset($_GET['cat_image'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Direct call to global variables is unacceptable. Please use RequestInterface to access request params.

$_GET['cat_image'] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Modifying global variables such as $_GET or $_POST, including operations that indirectly change their values (e.g., incrementation), is considered unacceptable.

}
$_GET['cat_image']++;
$isProductPage = ($block->getRequest()->getFullActionName() === 'catalog_product_view');
?>
<span class="product-image-container product-image-container-<?= /* @noEscape */ $block->getProductId() ?>">
<span class="product-image-wrapper">
Expand All @@ -19,7 +25,10 @@ $paddingBottom = $block->getRatio() * 100;
<?= $escaper->escapeHtmlAttr($name) ?>="<?= $escaper->escapeHtml($value) ?>"
<?php endforeach; ?>
src="<?= $escaper->escapeUrl($block->getImageUrl()) ?>"
<?php if ($_GET['cat_image'] > 1 || $isProductPage) { ?>
loading="lazy"
fetchpriority="low"
<?php }?>
width="<?= $escaper->escapeHtmlAttr($block->getWidth()) ?>"
height="<?= $escaper->escapeHtmlAttr($block->getHeight()) ?>"
alt="<?= $escaper->escapeHtmlAttr($block->getLabel()) ?>"/></span>
Expand Down