In a Symfony 5 project E-Mails are created using the Mailer components TemplatedEmail() function. In the used twig template ($templatedEmail->htmlTemplate(..)) an image is embedded using
<img src="{{ email.image('@v_images/user-'~user.id~'/v.jpg') }}">
to include a user-specific image. This works fine. When trying to pass that image to liip filters by
<img src="{{ email.image('@v_images/user-'~user.id~'/v.jpg') | imagine_filter('v_watermark') }}">
the image deosn't render anymore. I was thinking about the resolver settings to be applied to make liip able to read from the non-standard target path - but didn't find any sensible setting. Documentation didn't lead me to any helpfull information. For any hints on how to make liip work with Mailer embedded images would help me a lot.
EDIT (thanks @ArleighHix):
I also tried nesting the filter inside the call like
<img src="{{ email.image('@v_images/user-'~user.id~'/v.jpg' | imagine_filter('v_watermark')) }}">
which resulted in the following error:
Unable to find template "@v_images/user-1https:/127.0.0.1:8000/media/cache/resolve/v_watermark/v.jpg" (looked into: [SENSIBLE_LOCAL_PATH_IN_PROJECT]).
I am unsure what exactly happens but the path seems to be concatenated weirdly...
I think you should use absolute_url() combine with asset().
Base on this doc
Solution 1
I think this one should work :
Solution 2
If it don't work, you should add a gloabl variable with base url.
twig.yaml
And use it as :
Of course as you'll publish your website on the web, the base_url would change. You may use a service parameter
'%app.base_url%'
Define it in you configuration files :
services_dev.yaml
services_prod.yaml
And then update your twig.yaml as