Select to view content in your preferred language

Display Image in Pop Up using conditional statements.

713
4
02-15-2024 06:22 AM
Skysurfer
Emerging Contributor

I have a field named CVA_Partner_ and it has a value of either yes or no. If it is yes, Yes, Y, or y, I need it to display an image in the pop-up. Otherwise I don't want anything to display. I selected 'add content', 'image', and I placed the an expression in the URL field, but nothing happens in the pop up. I seem to be confused have this works.

Below is the expression: 

if ($feature.CVA_Partner_ == "yes" || $feature.CVA_Partner_ == "Yes" || $feature.CVA_Partner_ == "Y" || $feature.CVA_Partner_ == "y") {
  return '<img src=".../sharing/rest/content/items/78df60bf1f274f26b96176d9975cdbf7/data" alt="Image">'
}
 
0 Kudos
4 Replies
Amir-Sarrafzadeh-Arasi
Frequent Contributor

Dear Skysurfer,

Hope this message finds you well,

Please follow this steps if you are using ArcGIS Pro,

1) Right click on the feature layer in the content pane and select Configure Pop-ups,

2) In the Configure Pop-ups Pane click on Arcade in the right up corner 

3) Define a name for you pop-up in the Title field

4) Double clikc on the Expression in the below of the Title and paste the arcade.txt which I put in the attachment.

 

It should work,

if you need more info please let me know

Best wishes

 

Amir Sarrafzadeh Arasi
0 Kudos
Skysurfer
Emerging Contributor

I am using AGOL. So any other solutions would be great.

 

0 Kudos
KenBuja
MVP Esteemed Contributor

Instead of using the Image content, use Arcade element. This would be your expression

var output;
if (Lower($feature.CVA_Partner_) == "yes" || Lower($feature.CVA_Partner_) == "y") output = '<img src=".../sharing/rest/content/items/78df60bf1f274f26b96176d9975cdbf7/data" alt="Image">'

return { 
	type : 'text', 
	text : output //this property supports html tags 
}

 

0 Kudos
Amir-Sarrafzadeh-Arasi
Frequent Contributor

Dear Skysufer,

As @KenBuja said, you can use in AGOL his method,

I have created a sample Feature layer which you can find the link below.

https://www.arcgis.com/apps/mapviewer/index.html?panel=gallery&suggestField=true&layers=d98fe2be4dd7...

If you click on items you will see one of the below images,

 

happy.png

 

sad.png

Please find the updated arcade.txt file in the attachment. Please copy the arcade.txt file content in the Pop-ups section click on Add Content, select Arcade, delete what is inside and paste the arcade.txt file content in it.

If you need more clarification please let me know.

Best wishes, Stay Safe 

Amir Sarrafzadeh Arasi
0 Kudos