One of my extension using the below code to retrieve product image in listing page.

$productImage = $block->getImage($_product, $image);

getImage() method presents in vendor/magento/module-catalog/Block/Product/AbstractProduct.php

public function getImage($product, $imageId, $attributes = [])
    return $this->imageBuilder->setProduct($product)

But the above one always return placeholder image instead of product image.

Note : We have all the product images in pub/media/catalog/product/cache (bin/magento catalog:images:resize) but somehow above one always return placeholder.

any ideas? how to debug? how to find the actual image URL?

1 Answer 1


You can try to add Module_Vendor/Module_Name/etc/view.xml with $imageId you use. E.g. $imageId = 'product_thumbnail_image':

<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
    <images module="Magento_Catalog">
        <image id="product_thumbnail_image" type="thumbnail">

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.