4

I want to add itemprop="image" to main image on product page. How can I achieve this.

enter image description here

3
  • see image.phtml file file path:- vendor/magento/module-catalog/view/frontend/templates/product/image.phtml Commented Jul 29, 2016 at 12:48
  • @MagikVishal thanks for your response but it is not coming through there. Commented Jul 29, 2016 at 13:01
  • I'm having the same problem. Where exactly did you place the code in view/gallery.phtml file? Before the last < /div >? and do you overwrite the original gallery.phtml file located in vendor/magento/module-catalog/view/frontend/templates/product/gallery.phtml --- or --- vendor/magento/module-catalog/view/frontend/templates/product/view/gallery.phtml Thank you! Commented Jan 21, 2024 at 18:57

1 Answer 1

4

Add this:

<?php $imageUrl = $this->helper('Magento\Catalog\Helper\Image') ->init($block->getProduct(), 'product_page_image_large') ->setImageFile($block->getImageFile()) ->getUrl(); ?> <meta itemprop="image" content="<?php /* @escapeNotVerified */ echo $imageUrl; ?>" > 

To: app/design/frontend/<vendor>/theme/Magento_Catalog/templates/product/view/gallery.phtml

1
  • Thanks, It's working Commented Mar 13, 2019 at 9:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.