How can I get an image URL from the image name?
Please provide me steps and also let me where need to keep code(folder or file location) to get URL.

1 Answer 1


You can't get product image by product name only. You need to load product by SKU or ID and then you can get the image details using the following code.

$prdId = 35;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$prdoduct = $objectManager->get('Magento\Catalog\Model\Product')->load($prdId);
$store = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore();

$productImageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $prdoduct->getImage();
$productUrl  = $product->getProductUrl();
  • Magento 1+ I know only (/skin/frontend/default/default/images/color.jpg), now just want to know where in the frontend pages this images displaying.
    – irshad
    Commented Aug 19, 2019 at 5:52

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.