How is \Magento\Catalog\Helper\Image::getUrl() implemented and used?

Implementation

Usage

1. \Magento\Catalog\Block\Product\View\Gallery::getGalleryImages()

2. \Magento\Swatches\Block\Product\Renderer\Configurable::getSwatchProductImage()

3. \Magento\Wishlist\Block\AbstractBlock::getImageUrl()

4. \Magento\Catalog\Block\Product\ImageBuilder::create()

/**
 * Create image block
 *
 * @return \Magento\Catalog\Block\Product\Image
 */
public function create()
{
	/** @var \Magento\Catalog\Helper\Image $helper */
	$helper = $this->helperFactory->create()
		->init($this->product, $this->imageId);

	$template = $helper->getFrame()
		? 'Magento_Catalog::product/image.phtml'
		: 'Magento_Catalog::product/image_with_borders.phtml';

	$imagesize = $helper->getResizedImageInfo();

	$data = [
		'data' => [
			'template' => $template,
			'image_url' => $helper->getUrl(),
			'width' => $helper->getWidth(),
			'height' => $helper->getHeight(),
			'label' => $helper->getLabel(),
			'ratio' =>  $this->getRatio($helper),
			'custom_attributes' => $this->getCustomAttributes(),
			'resized_image_width' => !empty($imagesize[0]) ? $imagesize[0] : $helper->getWidth(),
			'resized_image_height' => !empty($imagesize[1]) ? $imagesize[1] : $helper->getHeight(),
		],
	];

	return $this->imageFactory->create($data);
}

5. \Magento\Catalog\Block\Rss\Category::getRssData()

6. Magento\Catalog\Block\Rss\Product\NewProducts::getRssData()

7. \Magento\Catalog\Block\Rss\Product\Special::getEntryData()

8. Magento\Catalog\Ui\Component\Listing\Columns\Thumbnail::prepareDataSource()

9. \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Related::fillData()

10. \Magento\Checkout\CustomerData\DefaultItem::doGetItemData()

11. \Magento\Checkout\Model\DefaultConfigProvider::getQuoteItemData()

12. Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Matrix::prepareVariations()

13. \Magento\ConfigurableProduct\Helper\Data::getGalleryImages()

14. \Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\Data\AssociatedProducts::prepareVariations()

15. \Magento\GroupedProduct\Ui\DataProvider\Product\Form\Modifier\Grouped::fillData()

16. \Magento\SendFriend\Model\SendFriend::send()

17. \Magento\Swatches\Helper\Data::getAllSizeImages()

18. \Magento\Wishlist\CustomerData\Wishlist::getImageData()

/**
 * Retrieve product image data
 *
 * @param \Magento\Catalog\Model\Product $product
 * @return \Magento\Catalog\Block\Product\Image
 * @SuppressWarnings(PHPMD.NPathComplexity)
 */
protected function getImageData($product)
{
	/** @var \Magento\Catalog\Helper\Image $helper */
	$helper = $this->imageHelperFactory->create()
		->init($product, 'wishlist_sidebar_block');

	$template = $helper->getFrame()
		? 'Magento_Catalog/product/image'
		: 'Magento_Catalog/product/image_with_borders';

	$imagesize = $helper->getResizedImageInfo();

	$width = $helper->getFrame()
		? $helper->getWidth()
		: (!empty($imagesize[0]) ? $imagesize[0] : $helper->getWidth());

	$height = $helper->getFrame()
		? $helper->getHeight()
		: (!empty($imagesize[1]) ? $imagesize[1] : $helper->getHeight());

	return [
		'template' => $template,
		'src' => $helper->getUrl(),
		'width' => $width,
		'height' => $height,
		'alt' => $helper->getLabel(),
	];
}

19. \Magento\Wishlist\Model\Rss\Wishlist::getRssData()

20. Magento/Catalog/view/frontend/templates/product/gallery.phtml

See also: