Use variables in images

Your software
My Mautic version is:4.4.5
My PHP version is: 7.4.33
My Database type and version is: MariaDB

Your problem
My problem is:
Hi, (first post!)
I would like to know how i can use variables in an image (source) when creating a new email template.
I would like to add an image in the email for which we store the path in a custom field on the contact (imageUrl).

When adding an image, i can only select one from the uploaded images…



Hi, welcome to the Community!

this is how you can achieve this:

  1. Create a custom field (Ger Icon / Custom Fields). Choose Text and connect it with Contact entity, not Company.
  2. The alias field will be automatically generated, don’t fill it out, but remember the alias field. Let’s call it “imgurl” for now.
  3. Go back to your email editor and add modify the URL to:
    a href="{contactfield=imgurl}"
    This will embed the right URL when you test.

Important: Tokens are only merged if you do a segment send or campaign action send AKA real send. When you test, the IMG url token won’t be rendered.

1 Like

Hi @joeyk ,
I did not mean the url in an anchor but the src url in an image, eg.

Doesn’t matter. You can use the same way. But you need to go to the code, not on the visual surface.

Hi @joeyk ,
Thanks for helping (and your youtube channel), it worked!

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.