I want to add itemprop="image" to main image on product page. How can I achieve this.
- see image.phtml file file path:- vendor/magento/module-catalog/view/frontend/templates/product/image.phtmlVishal– Vishal2016-07-29 12:48:21 +00:00Commented Jul 29, 2016 at 12:48
- @MagikVishal thanks for your response but it is not coming through there.Prashant Valanda– Prashant Valanda2016-07-29 13:01:20 +00:00Commented 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!Aurel– Aurel2024-01-21 18:57:15 +00:00Commented Jan 21, 2024 at 18:57
Add a comment |
1 Answer
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
- Thanks, It's workingSudheer Singamsetti– Sudheer Singamsetti2019-03-13 09:41:33 +00:00Commented Mar 13, 2019 at 9:41
