diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml index ba0ab0c91f393..b8b9fac28a524 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml @@ -11,6 +11,18 @@ $width = (int)$block->getWidth(); $height = (int)$block->getHeight(); $paddingBottom = $block->getRatio() * 100; + +$globalBlock = $block->getLayout()->getBlock('header'); +if ($globalBlock) { + $catImage = $globalBlock->getData('cat_image_counter') ?? 0; + $catImage++; + $globalBlock->setData('cat_image_counter', $catImage); +} else { + $catImage = 10; +} + +$isProductPage = ($block->getRequest()->getFullActionName() === 'catalog_product_view'); +$isHomePage = ($block->getFullActionName() === 'cms_index_index'); ?> @@ -18,8 +30,14 @@ $paddingBottom = $block->getRatio() * 100; getCustomAttributes() as $name => $value): ?> escapeHtmlAttr($name) ?>="escapeHtml($value) ?>" - src="escapeUrl($block->getImageUrl()) ?>" + src="escapeUrl($block->getImageUrl())?>" + 1 || $isProductPage || $isHomePage) { ?> loading="lazy" + fetchpriority="low" + + loading="eager" + fetchpriority="high" + width="escapeHtmlAttr($block->getWidth()) ?>" height="escapeHtmlAttr($block->getHeight()) ?>" alt="escapeHtmlAttr($block->getLabel()) ?>"/>