1

I want to return the image URL using getBaseUrl() function but I can't understand what value to set to the $value variable.

$url = $this->_storeManager->getStore()->getBaseUrl(
    \Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/category/' . $value;
  • are you looking to used this function for fetching image from media? – Dhiren Vasoya Dec 22 '17 at 13:18
  • @DhirenVasoya, to fetch images from categories of the catalog. – Diego Queiroz Dec 26 '17 at 11:43
0

$value needs to be the name of the image filename. e.g. my_category_image.jpg

For example:

Place an image in pub/media/catalog/category/my_category_image.jpg then use $value = my_category_image.jpg to test and see if it appears:

http://magento-site.com/pub/media/catalog/category/my_category_image.jpg
| improve this answer | |
  • I marked your answer as right because when you know the image name, the function returns the full URL of the image, but I wanted to return dynamic images from the category of catalog and I did that with other method. Thank's. – Diego Queiroz Dec 26 '17 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.