I would like to get product image in reviews, can anyone help with some advice on how to do it?

Currently I have magento reviews - enter image description here

And what I would like to get is like this - enter image description here

Thank you a lot!


In your custom theme create directory as


In review.phtml file write following code

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $product = $objectManager->get('Magento\Framework\Registry')->registry('current_product');//get current product

    $helperImport = $objectManager->get('\Magento\Catalog\Helper\Image');

    $imageUrl = $helperImport->init($product, 'product_page_image_small')
                    ->setImageFile($product->getSmallImage()) // image,small_image,thumbnail

<img src="<?php echo $imageUrl  ?>" />

I hope this will help you.

| improve this answer | |
  • It works, but is it possible to do this without using objectmanager? Thank you a lot! :) – help Dec 14 '18 at 12:30

Don't use ObjectManager directly in phtml files Learn More

1) Override class Magento\Review\Block\Product\Review


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Review\Block\Product\Review" type="Vendor\Module\Block\Product\Override\Review" />

2) Create Review.php



namespace Vendor\Module\Block\Product\Override;

class Review extends \Magento\Review\Block\Product\Review
    protected $imageHelperFactory;

    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        \Magento\Framework\Registry $registry,
        \Magento\Review\Model\ResourceModel\Review\CollectionFactory $collectionFactory,
        \Magento\Catalog\Helper\ImageFactory $imageHelperFactory,
        array $data = []
    ) {
        $this->imageHelperFactory = $imageHelperFactory;
        parent::__construct($context, $registry, $collectionFactory, $data);

    public function getProductImage()
        $product = $this->_coreRegistry->registry('product');
        $imageUrl = $this->imageHelperFactory->create()
            ->init($product, 'product_base_image')->getUrl();

        return $imageUrl;

3) Now in review.phtml call getProductImage() function to get image url


 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

/** @var \Magento\Review\Block\Product\Review $block */
    <img src="<?= $block->getProductImage() ?>" />
<div id="product-review-container" data-role="product-review"></div>
<?= $block->getChildHtml() ?>

<script type="text/x-magento-init">
        "*": {
            "Magento_Review/js/process-reviews": {
                "productReviewUrl": "<?= $block->escapeJs($block->escapeUrl($block->getProductReviewUrl())) ?>",
                "reviewsTabSelector": "#tab-label-reviews"
| improve this answer | |
  • hi @prince patel, can you look into this issue please, magento.stackexchange.com/questions/253672/… – jafar pinjar Dec 14 '18 at 14:43
  • @PrincePatel Hey, thank you a lot for your help, it works, but question - how can I call it not inside review.phtml file but inside list.phtml file? Because if I call it inside review.phtml file it works, but if I call it inside list.phtml file it says "unknown" – help Dec 18 '18 at 12:00
  • @help for list.phtml you need to override class Magento\Catalog\Block\Product\ListProduct – Prince Patel Dec 18 '18 at 13:24
  • @PrincePatel Can you maybe please update your answer and show how to override that class? I keep getting unknown. P.S. I need to display image in module-review/frontend/templates/product/view/list.phtml, is it really the right file you are saying that I need to override? – help Dec 18 '18 at 14:15
  • @help This question is about show product image on the review tab. Please ask another question for show image on the list page to keep clean and clear comments on this queue :) – Prince Patel Dec 19 '18 at 4:47

at Magento_Review\templates\form.phtml add this code :

foreach ($block->getProductInfo()->getMediaGallery('images') as $image) {
    $imageUrl = $block->getProductInfo()->getMediaConfig()->getMediaUrl($image['file']);

and then you can show the image like this :

<img class="product-image" src="<?= $imageUrl ?>" />

Magento ver. 2.3.1

| improve this answer | |

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.