TWIG dataUrl function for resized images Craft provides the very nice TWIG function dataUrl(pathToImg) to inline images in e-mails.
E.g.
&lt;img src=&quot;{{ dataUrl('@webroot/assets/img/logo.svg')&quot; /&gt;

will base64 encode the image into the src. This also works if you pass in an instance of an asset:
{% set myAsset = craft.assets.id(123).one() %}
&lt;img src=&quot;{{ dataUrl(myAsset) }}&quot; /&gt;

My question: Does anyone know how to resize the image first, if you pass in an asset?
This does not work:
&lt;img src=&quot;{{ dataUrl(myAsset.getUrl({width: 200, height: 200})) }}&quot; /&gt;
Found it, this works:
&lt;img src=&quot;{{ dataUrl('@webroot' ~ myAsset.getUrl({width: 200, height: 200}, true)) }}&quot; /&gt;

Two important things:

prepend the @webroot alias to the myAsset.getUrl(...)
set the second parameter of getUrl(...) to true: myAsset.getUrl({...}, true). This ensures that a real file path is returned by getUrl, because the image is transformed immediately on call. This is necessary for the dataUrl function to work. If it is not present, Craft might return a URL pointing to the image transformation controller (which transforms when called for the first time, this might go wrong here).