You can get media url in your template file using below way but without using objectmanager you must have to define Block file with __construct() method with define storeManagerInterface in construct method.
In your phtml Block file create __construct function.
Add to __construct
in your class
protected $_storeManager;
public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
{
$this->_storeManager = $storeManager;
}
Add new method in your class
public function getMediaUrl($path)
{
return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $path;
}
Call in phtml
<img src="<?php echo $block->getMediaUrl('wysiwyg/img.jpg') ?>" />
This is the +- proper way to get media url in Magento 2.
great