Magento 2 product image in new order email

I did that by copying vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtml to my template folder app/design/frontend/[VENDOR]/[TEMPLATE]/Magento_Sales/templates/email/items/order/default.phtml and adding the image column there...

$_item = $block->getItem();
$_order = $_item->getOrder();
$_store = $_order->getStore();


$_imageHelper = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Catalog\Helper\Image');
$_baseImageUrl = $_store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'catalog/product';

and right below

<img src="<?= $_imageHelper->init($_item->getProduct(), 'small_image', ['type'=>'small_image'])->keepAspectRatio(true)->resize('65','65')->getUrl();?>" alt="<?= __('Product Image');?>">

As addition to Ricardo Martins answer. I had to show the children product image of configurable products. Here is the code for those who have the same problem .

    <?php if($childProd = current($_item->getChildrenItems())):  ?>
        <img src="<?= $_imageHelper->init($childProd->getProduct(), 'small_image', ['type'=>'small_image'])->keepAspectRatio(true)->resize('65','65')->getUrl();?>" alt="<?= __('Product Image');?>">
    <?php else: ?>
        <img src="<?= $_imageHelper->init($_item->getProduct(), 'small_image', ['type'=>'small_image'])->keepAspectRatio(true)->resize('65','65')->getUrl();?>" alt="<?= __('Product Image');?>">               
    <?php endif; ?> 

Tags:

Magento2