Select to view content in your preferred language

Webmap Popup - Handle Missing Images

113
3
Monday
ZorbaConlen1
Frequent Contributor

Hi. My webmap displays an image in the popup, with the source attribute dynamically created like this:

"https://<domain>/Images/SurveyReports/" + Text($feature.CONTROLID) + ".gif".
 
Works fine, but there are some features that lack an image in that folder. In that case, I'd like to automatically display an alternate image. Like a placeholder that shows something like 'comming soon' or 'no image found'.
 
Note that there is no field in the layer that indicates existence of the image in that folder, so I can't use arcade to check a field and specify a different url dynamically.
 
html img tag does have an onerror attribute, but it appears it's not supported in popup elements. 
 
My other thought is to try ussing css to stack two imges one on top of the other, with the alternate image being below the other image so that if that top image does not exist, the bottom one would be visible. Not not sure how to accomplish this with inline css.
 
Any ideas?
 
Thanks. 
0 Kudos
3 Replies
NicoleJohnson
Frequent Contributor

Edit: I didn't think this through properly--sorry! I'll blame it on it being close to 5 pm. The problem (like you said) is that since there's nothing to indicate whether a record has an image, I'm not sure there's a way in Arcade to actually check if that URL is reachable. 

I'll still leave this up in case it helps anyone else, though.

-----------------------------------------------------------------------------------------

@ZorbaConlen, I think you can actually use Arcade here!

I'm assuming this is how you're getting the image into the pop-up:

NicoleJohnson_0-1765229485966.png

 

If so, click on "Attribute expressions" and create an expression something like this:

// The first parameter is your constructed image URL
// The second parameter is your backup/no-image image URL (I grabbed a random image from the ArcGIS blog)
return DefaultValue("https://<domain>/Images/SurveyReports/" + Text($feature.CONTROLID) + ".gif", "https://www.esri.com/arcgis-blog/wp-content/uploads/2025/11/CapBld_WIDE.png")

 

Once you have that expression created, you should be able to choose it as a "field" (click on the curly brackets):

NicoleJohnson_1-1765229744198.png

 

ZorbaConlen1
Frequent Contributor

Hi Nicole. Thanks for the reply. 

So, I am able to use an arcade expression. I'm not using the media element, but rather a text element and I configure the img tag in html mode, using the arcade expression for the source attribute. That part is all good. The challenge I'm facing is like this. There are about 5k control points. Most have a corresponding image on my web server, but some don't have an image there. I don't know which points are missing an image, so I'm looking for a way to display an alternate image in the popup for those that don't have one. 

 

0 Kudos
NicoleJohnson
Frequent Contributor

Right--I think what you're needing to test is whether the URL is reachable, which I don't think is possible in Arcade right now. I did find this discussion that mentions using a bulk URL status code checker: Solved: Re: Arcade Validate URL in Popup - Esri Community

You could then use the results to create a new field in the data (if you have the appropriate access) to track whether the record has an image, then base your expression on that field:

var image

if ($feature.HASIMAGE == 'Y'){
  image = "https://<domain>/Images/SurveyReports/" + Text($feature.CONTROLID) + ".gif"
} else {
  image = "https://www.esri.com/arcgis-blog/wp-content/uploads/2025/11/CapBld_WIDE.png" // back-up image
}

return image

 

0 Kudos