Commit be809ca3 by liumengfei

优化列表页面图片加载

parent e601eb60
......@@ -96,6 +96,7 @@ $_helper = $block->getData('outputHelper');
data-container="product-<?= /* @noEscape */ $viewMode ?>">
<?php
$productImage = $block->getImage($_product, $imageDisplayArea);
$baseImageUrl = $productImage->getImageUrl();
$allImage = $_product->getMediaGalleryImages()->getItems();
$hoverImg = '';
......@@ -105,6 +106,7 @@ $_helper = $block->getData('outputHelper');
break;
}
}
if ($pos != null) {
$position = 'left:' . $productImage->getWidth() . 'px;'
. 'top:' . $productImage->getHeight() . 'px;';
......@@ -114,9 +116,12 @@ $_helper = $block->getData('outputHelper');
<a href="<?= $escaper->escapeUrl($_product->getProductUrl()) ?>"
class="product photo product-item-photo"
tabindex="-1">
<?= $productImage->toHtml() ?>
<?php
$productImageRaw = $imageHelper->init($_product, $imageDisplayArea)->setImageFile($productImage->getFile())->resize($productImage->getWidth(),$productImage->getHeight())->getUrl();
?>
<img class="product-image-photo" data-src="<?= $productImageRaw ?>" loading="lazy" width="<?= $productImage->getWidth() ?>" height="<?= $productImage->getHeight() ?>" alt="Image">
<?php if ($hoverImg): ?>
<img class="hoverImg" width="<?= $productImage->getWidth() ?>" height="<?= $productImage->getHeight() ?>" data-src="<?= $hoverImg ?>">
<img class="hoverImg" width="<?= $productImage->getWidth() ?>" height="<?= $productImage->getHeight() ?>" data-src="<?= $hoverImg ?>" loading="lazy" />
<?php endif; ?>
</a>
<div class="product details product-item-details">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment