I am trying to get URL of small_image.
Magento 2 offers a helper helper('Magento\Catalog\Helper\Image')
.
I used this code to load small_image
<?php echo $this->helper('Magento\Catalog\Helper\Image')->init($block->getProductForThumbnail(), 'small_image')
->setImageFile($block->getProductForThumbnail()->getImage())
->resize(165, 165)->getUrl(); ?>
But this code throws me this error.
Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Catalog\Model\Product\Image::loadImageInfoFromCache() must be of the type string, null given, called in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 612 and defined in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 892
How to get small_image