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

enter image description here

  • see image.phtml file file path:- vendor/magento/module-catalog/view/frontend/templates/product/image.phtml Jul 29 '16 at 12:48
  • @MagikVishal thanks for your response but it is not coming through there. Jul 29 '16 at 13:01

Add this:

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

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


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.