I am in the process of trying to add a product image to each order item displayed on the sales/order/view page located inside the user account area of Magento2.

What is the most efficient way of retrieving the product image URL from inside the following template file?


2 Answers 2


You can use $_item->getProduct()->getImage() to get the product image.

  • Hi DMatthew, Thanks for your response. I'm not sure this is the best way. If an image is uploaded at 100MB then this method would return the 100MB image rather than return an optimised version which you can set the size of. Mar 21, 2017 at 10:10

To get the product image I used the following helper:

$image_helper = $this->helper('Magento\Catalog\Helper\Image');

And then retrieved the image URL like so:

<img src="<?php echo $image_helper->init($_item->getProduct(), '[image id set inside view.xml goes here]')->getUrl() ?>" alt="<?php echo $block->escapeHtml($_item->getName()) ?>">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.