Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Image.php
Go to the documentation of this file.
1 <?php
14 
18 
19 class Image extends AbstractFrontend
20 {
26  protected $_storeManager;
27 
33  public function __construct(StoreManagerInterface $storeManager)
34  {
35  $this->_storeManager = $storeManager;
36  }
37 
45  public function getUrl($product)
46  {
47  $image = $product->getData($this->getAttribute()->getAttributeCode());
48  $url = false;
49  if (!empty($image)) {
50  $url = $this->_storeManager
51  ->getStore($product->getStore())
52  ->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . 'catalog/product/' . ltrim($image, '/');
53  }
54  return $url;
55  }
56 }
__construct(StoreManagerInterface $storeManager)
Definition: Image.php:33
$storeManager