I have created custom module for get category's products which are assigned to particular category like "Featured Product". Feature product is a category and it has a many products. i got that array by developing custom module but i don't know how to get resized image for that product.

please help me Thank you.

1 Answer 1


You can use the below function to resize the product base image and get resized image URL.

public function __construct(
    \Magento\Catalog\Block\Product\Context $productContext,
) {    
    $this->productImageHelper = $productContext->getImageHelper();

function getImageUrl($productObject)
     $width = 180;
     $height = 180;

     $resizedImage = $this->productImageHelper
        ->init($productObject, 'product_base_image')
        ->resize($width, $height)

      return $resizedImage;

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.