How to get the media folder URL programmatically

Magento 2 stores media data (including images) in the pub/media folder .
The function below returns its url for the current store.
The url looks like http://site.com/pub/media/ (but may be more complex).

/** @return string */
function getMediaBaseUrl() {
	/** @var \Magento\Framework\ObjectManagerInterface $om */
	$om = \Magento\Framework\App\ObjectManager::getInstance();
	/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
	$storeManager = $om->get('Magento\Store\Model\StoreManagerInterface');
	/** @var \Magento\Store\Api\Data\StoreInterface|\Magento\Store\Model\Store $currentStore */
	$currentStore = $storeManager->getStore();
	return $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
}

Please note that the method getBaseUrl is absent in \Magento\Store\Api\Data\StoreInterface and pesents in a particular interface implementation only: \Magento\Store\Model\Store
https://github.com/magento/magento2/issues/2222

nice worked well :smile: