# Use variables in images

**URL:** https://forum.mautic.org/t/use-variables-in-images/26931
**Category:** Product Support
**Created:** [February 1, 2023, 8:12pm UTC](https://forum.mautic.org/t/use-variables-in-images/26931 "2023-02-01T20:12:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ruben123](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ruben123/32/9240_2.png) [@ruben123](https://forum.mautic.org/u/ruben123)
#### Post date: [February 1, 2023, 8:12pm UTC](https://forum.mautic.org/t/use-variables-in-images/26931/1 "2023-02-01T20:12:14Z")

</div>

**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…

Thanks!

Ruben

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [February 2, 2023, 7:19am UTC](https://forum.mautic.org/t/use-variables-in-images/26931/2 "2023-02-02T07:19:07Z")

</div>

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.**

---

<div class="post-metadata">

### Author: ![ruben123](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ruben123/32/9240_2.png) [@ruben123](https://forum.mautic.org/u/ruben123)
#### Post date: [February 2, 2023, 3:46pm UTC](https://forum.mautic.org/t/use-variables-in-images/26931/3 "2023-02-02T15:46:36Z")

</div>

Hi @joeyk ,  
I did not mean the url in an anchor but the src url in an image, eg. ![]()

 ![2023-02-02 16_45_01-Edit Email - Test email _ Mautic](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/3/30015245bc9498bb70dcf02a9fc731af7ba5f451.png)

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [February 2, 2023, 4:06pm UTC](https://forum.mautic.org/t/use-variables-in-images/26931/4 "2023-02-02T16:06:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ruben123](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ruben123/32/9240_2.png) [@ruben123](https://forum.mautic.org/u/ruben123)
#### Post date: [February 3, 2023, 10:09am UTC](https://forum.mautic.org/t/use-variables-in-images/26931/5 "2023-02-03T10:09:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)
#### Post date: [February 4, 2023, 10:10pm UTC](https://forum.mautic.org/t/use-variables-in-images/26931/6 "2023-02-04T22:10:05Z")

</div>

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