magento,  MAGENTO2

How to show product image from product id in phtml page magento 2

The following code will show the product image from given product id

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$b=1232;  // product id 
$productd = $objectManager->get('Magento\Catalog\Model\Product')->load($b);

<div class="product-image"> 
    <img src="<?php echo $productd->getMediaConfig()->getMediaUrl($productd->getImage()); ?>" >
 </div> 

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × three =