3

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

enter image description here

2
  • 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
2

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

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.