enter image description here

Friend please help me how to get product images and thumbnail images.

  • you need to get Thumbnail product URL from Product collection? Commented Jul 16, 2018 at 19:19
  • so sir complete code given i have new developer so very problem understating. in magento code so please given on this code
    – pushpendra
    Commented Jul 16, 2018 at 19:23
  • I can not understand your question. Can you please specify where you want to show that thumbnail image? Commented Jul 16, 2018 at 19:25
  • wait i can explain
    – pushpendra
    Commented Jul 16, 2018 at 19:25
  • Yes. please explain in details. Commented Jul 16, 2018 at 19:27

1 Answer 1


You need to inject the ImageBuilder class in our block :

protected $_imageBuilder;

public function __construct(
    \Magento\Catalog\Block\Product\ImageBuilder $_imageBuilder

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

=> This is default image type :

$imageType = 'product_base_image';  //For getting the base image
$imageType = 'product_small_image';  //For getting the small image
$imageType = 'product_thumbnail_image';   //For getting the thumbnail image

Now, get thumbnail image in phtml file :

    $imageType = 'product_thumbnail_image'; //for thumbnail image
    $image = $block->getImage($_item, $imageType);

<img src = "<?php echo $image->getImageUrl(); ?>" />

Hope, It may be helpful for you !!

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.