SOLVED

How do I use an image for the Default content in a token?

Go to solution
Guitarrista82
Level 6

How do I use an image for the Default content in a token?

Hello Community,

 

We want to use an image as the default content for an image token we've created. Is this possible to do?

 

I tried simply pasting the image link as shown below, but the image doesn't appear when previewing the email in default mode:

Guitarrista82_0-1686676448060.png

 

default image.png

 

Thank you,

LK

 

1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How do I use an image for the Default content in a token?

Well, you can output the plain image URL from the velocity script token in the already existing image tag of your editable module, or you can also copy over the styles from here to the image tag in the velocity script token (in this case, you'd have to remove the already existing image tag in your editable module, as it's gonna be part of the velocity script). It's up to you how you want to do it. For the former case (i.e., just output the image URL from the velocity token), your script would look like something below. Add this velocity my token in the src attribute of the image tag in the editable module in the email and you should be good. Looking at your use-case you're better off with approach 1, i.e., outputting the image URL from the velocity token and plugging the token in the src attribute as I discussed above.

 

#if(!$lead.DestinationImageLink.isEmpty())
#set($imageURL = $lead.DestinationImageLink)
#else
#set($imageURL = "https://cdn3.redweek.com/photos/full/3/6/4/364719.jpg?1")
#end
${imageURL}

 

 

View solution in original post

15 REPLIES 15
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How do I use an image for the Default content in a token?

I'd rather use velocity for this. If the lead field is empty (assuming it'd have the image URL), then use the catch-all default image URL.

 

Guitarrista82
Level 6

Re: How do I use an image for the Default content in a token?

Thank you @Darshil_Shah1 ,

 

How would I configure this? 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How do I use an image for the Default content in a token?

A simple if else conditional construct should suffice. Assuming the correct name of the lead token in the email script editor is $lead.DestinationImageLink and if populated, it'd always contain a link to the image:

#if(!$lead.DestinationImageLink.isEmpty())
#set($imageURL = $lead.DestinationImageLink)
#else
#set($imageURL = "https://default/img/url.png")
#end
<img src="$imageURL">

 

Guitarrista82
Level 6

Re: How do I use an image for the Default content in a token?

Thank you @Darshil_Shah1!

 

I created the script but it's not working when I preview the email with the Default setting or with a test account that has no data in the Destination Image Link field.

 

Below is the Lead token:

 

Guitarrista82_0-1686754228512.png

 

Where image should appear in email:

Retargeting email.png

 

Email script with token enabled and image URL added:

Guitarrista82_1-1686754344546.png

 

Anything I might be missing?

 

Thank you,

LK

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How do I use an image for the Default content in a token?

Could you please add the velocity script token instead of using the {{lead.Destination Image Link}} token in the email?

 

Guitarrista82
Level 6

Re: How do I use an image for the Default content in a token?

Yes, I tried that as well and this is what I see:

reageting email preview.png

Guitarrista82
Level 6

Re: How do I use an image for the Default content in a token?

@Darshil_Shah1  Okay, I reworked the code as shown below, and it appears to be working BUT the image size is huge.

#if(!$lead.DestinationImageLink.isEmpty())
#set($imageURL = "https://promos.ovstravel.com/rs/512-JJP-615/images/Destinations by Spinnaker Logo 350px.png")
#else
#set($imageURL = $lead.DestinationImageLink)
#end
<img src="$imageURL">

 

How do I update the script to make the image smaller?

 

Guitarrista82_0-1686756763227.png

Thank you,

LK

 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How do I use an image for the Default content in a token?

Yes, you'd need to add appropriate CSS styles in the image tag so the image's height/width/appearance matches your requirement. Additionally, you may have a bug in your code above- you're setting the default image URL when the Destination Image Link is not empty (in the if's body) and setting the Destination Image Link field's value when it's empty (in the else's body), however, you wanna do the reverse of it I believe.

 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How do I use an image for the Default content in a token?

The below script works for me. I see the default content in the email preview well. Note- you'd need to add apt styles to the image tag so it meets your requirements around its appearance, but that's after you see the image in the email preview in the first place.

#if(!$lead.DestinationImageLink.isEmpty())
#set($imageURL = $lead.DestinationImageLink)
#else
#set($imageURL = "https://cdn3.redweek.com/photos/full/3/6/4/364719.jpg?1")
#end
<img src="$imageURL">