June 4, 2016 1:24 pm
image_round

Magento 2 : How to get product image ?

Follow this Code .

<?php
  $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProduct()->getId());

    $image = 'wishlist_thumbnail';
    $_imagehelper = $this->helper('Magento\Catalog\Helper\Image');
    $productImage = $_imagehelper->init($_product, $image)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(200)->getUrl();
?>
<img src="<?php echo $productImage; ?>" alt="<?php echo $_product->getName() ?>" />

Magento 2 : How to get product image ?

Follow this Code .

<?php
  $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProduct()->getId());

    $image = 'wishlist_thumbnail';
    $_imagehelper = $this->helper('Magento\Catalog\Helper\Image');
    $productImage = $_imagehelper->init($_product, $image)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(200)->getUrl();
?>
<img src="<?php echo $productImage; ?>" alt="<?php echo $_product->getName() ?>" />