How to get the media folder URL programmatically in Magento 2

- Magento 2

Magento 2 Development

Magento 2 uses the pub/media folder for storing images and other media data. The following function returns its url for the current store:

The getBaseUrl method is absent in \Magento\Store\Api\Data\StoreInterface. It is represented only in particular interface implementations.

Source

More tips from the Cookbook