Question

I want to add a New <div> in inside class="product-image-container" in Magento 2 I have searched and found that this class is rendered like this

$productImage = $block->getImage($_product, $imageDisplayArea);
<?= $productImage->toHtml() ?>

How I can do this task please let me know thank you

Was it helpful?

Solution

You can archive this by overridden the below file,

vendor/magento/module-catalog/view/frontend/templates/product/image_with_borders.phtml

To your theme

app/design/frontend/Magento_Catalog/templates/product/image_with_borders.phtml

In this file, you can add the custom class inside the

<span class="product-image-container" style="width:<?= /* @escapeNotVerified */ $block->getWidth() ?>px;">

Save the file and clear cache, Hope this will work for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top