Equivalent of the CMS Directive {{media url="..."}} in Normal Block Templates

The rendering of this such URLs is done when displaying CMS pages or blocks in

\Mage_Core_Model_Email_Template_Filter::mediaDirective:

public function mediaDirective($construction)
{
    $params = $this->_getIncludeParameters($construction[2]);
    return Mage::getBaseUrl('media') . $params['url'];
}

Base on this code, just an

<img src="<?php echo Mage::getBaseUrl('media') ?>image.jpg">

can be used in the template


In a phtml template file:

Mage::getBaseUrl('media') . $url;

In a CMS block or page:

{{store direct_url="media/url"}}

The difference between {{media url="foo"}} and {{store direct_url="media/foo"}} is that the latter hardcodes the media directory path as media.
That might lead to issues when using a CDN or something, because it bypasses Mage::getBaseUrl('media').