<p dir="auto">There are a few other related issues regarding to this problem. But I think none of them explained why this is really needed.</p>
<p dir="auto">asset() by default, will only output a path that is absolute under the current domain. If assets_base_urls is set then it will output an absolute url with domain. This is generally fine in most cases. However if twig is used to generate an email template, we will always want an absolute url with domain name regardless of the assets_base_urls setting.</p>
<p dir="auto">Given that it is not easily possible to detect whether assets_base_urls is set, a better alternative is to accept a second parameter for asset(). If assets_base_urls is not set, then it will use the current domain and scheme. If otherwise then it will simply follow the original behaviour.</p>
<p dir="auto">Hey guys!</p>
<p dir="auto">Currently, there's no standard way of retrieving the absolute URL to an asset. This would be useful when generating asset paths in a template for an email. Would be cool a function like:</p>
<div class="highlight highlight-text-html-twig notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{{ asset_url('images/foo.jpg') }}"><pre class="notranslate">{{ asset_url(<span class="pl-s"><span class="pl-pds">'</span>images/foo.jpg<span class="pl-pds">'</span></span>) }}</pre></div>
<p dir="auto">The current solution is not pratical and breaks when using CDN.</p>
<p dir="auto">Thanks,<br>
Marcos</p>