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


You can archive this by overridden the below file,


To your theme


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.

| improve this answer | |
  • can i do this is custom module? – User 69 Apr 5 at 6:15
  • Yes, You can, Which Magento version you using? – Kishor Thummar Apr 5 at 6:22
  • i am using 2.3.4 – User 69 Apr 5 at 6:22
  • 1
    This image template file called in "create" function of "vendor/magento/module-catalog/Block/Product/ImageFactory.php" file. You can create the template file in your module and need to override this function in your module to set the custom template. – Kishor Thummar Apr 5 at 6:32
  • Ohh I got this thank you so much for Heo – User 69 Apr 5 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.