How to conditionally display image in popup

387
1
03-15-2023 07:01 AM
Labels (1)
ChristinaHoddinott1
Occasional Contributor

Hello! I am trying to create a popup that displays an image from the URL in the Picture field of my feature layer. However, some features do not have a picture URL and are null and in those cases I would like it to display nothing, instead of the broken image icon or the outline of where the image should be.

I have been messing around with different Arcade expressions and HTML tags but cannot seem to figure it out.

Is there any way to do this?

 

ChristinaHoddinott1_0-1678888809803.png

 

Tags (2)
0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

You should be able to do this with an Arcade popup element.

var photo_viz = Iif(IsEmpty($feature['photo_url']), 'none', '')

return { 
	type : 'text', 
	text : `<span style="display:${photo_viz}>Here's a photo!<img src="${feature['photo_url']}">`
}
- Josh Carlson
Kendall County GIS