Select to view content in your preferred language

Arcade expression to return HTML tag in pop-up if field is not empty

524
2
08-03-2023 03:43 PM
Labels (1)
swhitcombMCC
Occasional Contributor

I want my pop-up to show a photo (from a website) with a link to the site. But it should only show the photo if the Attachment_URL field is not empty. The specific HTML tag that should be returned is

<a href="{Attachment_URL}?size=full"><img class="image_resized" style="width:100%;" src="{Attachment_URL}?size=lg" alt="Photo of a tree"></a>

 Here's the expression I've tried, but it returns nothing on my pop-up.

var photoURL = `<a href="{Attachment_URL}?size=full"><img class="image_resized" style="width:100%;" src="{Attachment_URL}?size=lg" alt="Photo of a tree"></a>`

IIf (isEmpty($feature.Attachment_URL), '', photoURL)

What am I doing wrong?

2 Replies
KenBuja
MVP Esteemed Contributor

Where are you assigning the Attachment_URL? Try this instead

var photoURL = `<a href="{$feature.Attachment_URL}?size=full"><img class="image_resized" style="width:100%;" src="{$feature.Attachment_URL}?size=lg" alt="Photo of a tree"></a>`

IIf (isEmpty($feature.Attachment_URL), '', photoURL)

 

0 Kudos
swhitcombMCC
Occasional Contributor

That still doesn't work. I just get blank line even if there is a photo present.

0 Kudos