3

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)
        ->setImageId($imageId)
        ->setAttributes($attributes)
        ->create();
}

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.