Magento 2 get product image


Magento 2 get product image url We often need to get the product images while working with the products. We can get the image, thumbnail and small image from the product object simply. Here in this tutorial we are going to explain how you can get the product images from product object in Magento 2.


Magento 2 get product image Small | Thumbnail Image | Url Example |

You can get the product images such as image, thumbnail, small_image simply as below-

Magento 2 get product image url Example:

$productId = 100;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Catalog\Model\Product')->load($productId);
$image = $product->getData('image');
$thumbnail = $product->getData('thumbnail');
$smallImage = $product->getData('small_image');

Thus using the aobve method you can get the images selected for product.


Advertisements

Add Comment

📖 Read More