Show Attachments in Web Map Popup

12-14-2015 08:10 AM

Show Attachments in Web Map Popup

I work with a lot of customers that request the ability to display their feature service attachments in the web map's popup rather than a hyperlink.  The attached script will convert the feature services attachments URL to a field.  You can then display the attachment directly in the popup after some configuration.

Here is a screen shot on how attachments display within a web map popup by default:


Below are the steps to show the attached image directly in the popup:

1.  Add a TEXT/STRING field (i.e. "Picture")  to the feature service that can support a large amount of characters (i.e. 1,000).

2.  Execute the attached GP tool.

3.  Configure the pop-up to Show Images.  Ex:


The image will now display directly in the popup.  Ex:



  • the timeout for an ArcGIS Online feature service is set to the max of 15 days.
  • the timeout for an ArcGIS Server service is set to the default 'Lifespan of long lived token'.  The default is 1 day.  This can be changed by going to Server Manager > Security > Settings.  After the long lived token is updated, you can update the expiration parameter on line 33.
  • Since the token will timeout, you can update the parameters in the script so this can be executed with Windows Task Scheduler.  Here is an example of how to configure the parameters:

Update 9/8/17: GP tool will update ArcGIS Server services that are federated with Portal for ArcGIS

Update 9/27/17:  GP tool now works with ArcGIS Pro

Update 3/13/18:  Script is a single file that utilizes the requests module.  No longer have to specify a referer.



I'm having an error when running the script in Pro. It is saying that my web layer doesn't have attachments, but as you can see on the right-hand side of the image, that it does have attachments.


Orca Maritime‌ can you share the service to an AGOL Group and invite my user account (jskinner_CountySandbox)?

Has anyone figured out how to run this script without updating the editor tracking? I'd like to retain the editor username and last edit time stamp of my field collectors. I'm currently using hosted feature services in ArcGIS Online.

I figured out I could manually turn of editor tracking on the layer, save, run the script, turn it back on and save again. A little tedious, but it works. Now I just have to remember!

It would be nice to be able to include a "disable" and "re-enable" editor tracking function at the beginning and end of this GP tool. Maybe even allow you to toggle editor tracking off in the user dialog.

Hi Jake Skinner‌, i have the same problem, after a few days, my image don't display, i use arcgis Online

Dambé SANWOGOU‌ the pop-ups should be retained for 15 days before you have to execute the tool again.  Have you tried configuring the variables in the script and having Windows Task Scheduler run the script (see the example in the document)?  You could schedule the script to run nightly and you won't have to worry about the token expiring, which causes the images to no longer display.


When I take data with Collector for ArcGIS, (image included), I can not get the image to appear in the pop-up.

Only the link to it appears. What do I have to do to be able to insert it as an image?

In this window, the field of the images (attachments) does not appear.

Thank you

Carlos Colegios‌ follow the steps in this document.  You first will add a new TEXT field to your service, and then execute the attached tool to up this field with the URL to the attachments.


I created the image field (text), but I do not know how to run the

Attachments to Popup tool. I do it from ArcGIS Online. I unzip the tool and

that's where I arrived. What do I do with the unzipped file?

Can you tell me, please, how it is done?

Thank you


El lun., 17 jun. 2019 a las 14:19, Jake Skinner (<>)


GeoNet, The Esri Community | GIS and Geospatial Professional Community


Show Attachments in Web Map Popup

new comment by Jake Skinner

<> View

all comments on this document


Carlos Colegios‌ you will need to run the tool from ArcMap or ArcGIS Pro.

Hi Jake Skinner‌, I'm getting a similar error. I've checked that my feature service is enabled for editing and have added the index to the end of the URL. Any ideas why I'm getting this error?

Samantha Griffore‌ what type of authentication are you using for ArcGIS Online?  For example, are you using built-in users, Active Directory, ADFS?  This tool currently only supports built-in and Active Directory.

Also, could you share the service to a Group and then invite my user account (jskinner_CountySandbox)?

Jake Skinner‌ Invite has been sent. I believe we use local users, but I'm checking on that.

Samantha Griffore‌ your feature service URL is incorrect.  It should end with /2.  Here is how I had the tool setup:

Thanks Jake Skinner‌. Might be a silly question, but how do I know which index number to put in? Is it based on where it is in my list of items in my specific folder/group/content? "2" didn't work for me, trying other numbers now.

Samantha Griffore‌ if you go to the Details of the service, scroll all the way to the bottom, and click View:

This will open REST services directory page.  You can then see the index number of the layer (i.e. 2):

If you click on the layer name, you will see it appends /2 after /FeatureServer in the URL.

Thanks Jake Skinner‌. Unfortunately, still getting the same error. At this point it's not crucial, but a nice to have. I'll let you know if I figure it out.


Error: Line 34 -- "token = response.json()['token']": 'token'

Completed script Attachments to Popup...

Failed to execute (AttachmentstoPopup).

Hello Jake Skinner, I have this error after several attempts. Here is my error message.

Exécution du script AttachmentstoPopup...
ObjectID: 14 successfully updated.
Error:  Line 103 -- "": ('Connection aborted.', error(10054, 'Une connexion existante a d\xfb \xeatre ferm\xe9e par l\x92h\xf4te distant'))
Completed script AttachmentstoPopup...
Échec de l’exécution de (AttachmentstoPopup).
Échec à Wed Aug 28 16:05:48 2019 (temps écoulé : 19,92 secondes)

I also wanted to know if there is another way to display the images after 15 days.

Best regards,


Dambé SANWOGOU‌ can you send a screen shot of how you have the tool setup? 

If the service is hosted in ArcGIS Online, 15 days is the max, however you can script this and use Windows Task Scheduler to execute the script.  See the Notes section above.

Thanks Jake Skinner

Ok for this error :

Exécution du script AttachmentstoPopup...
ObjectID: 14 successfully updated.
Error:  Line 103 -- "": ('Connection aborted.', error(10054, 'Une connexion existante a d\xfb \xeatre ferm\xe9e par l\x92h\xf4te distant'))
Completed script AttachmentstoPopup...
Échec de l’exécution de (AttachmentstoPopup).
Échec à Wed Aug 28 16:05:48 2019 (temps écoulé : 19,92 secondes)

Best regards,


Dambé SANWOGOU‌ can you send a screen shot of the tool before you click OK/Run to execute it.  Example:

Jake Skinner‌ thait is the screenshot, i use arcmap 10.7.7

Dambé SANWOGOU‌ can you share the service to an ArcGIS Online Group and invite with my user account (jskinner_CountySandbox) to this Group?  I can run a test with the service.

Jake Skinner‌ Invitation sent.


Dambé SANWOGOU‌ the feature service does not have editing enabled.  You need to enable this since this tool updates a field.

Hi Jake, thanks for clarifying that you need to enable editing above. I had to create a new View, make it editable and use that service URL in the script (the layer I am updated is public so I shouldn't enable editing on it).

I'm attempting to schedule this with Windows Task Scheduler and have altered the script as in your Notes. However, there is no attribute "disable_warnings' in the requests module. Any ideas?

Here is the error:

>>> import requests
>>> requests.packages.urllib3.disable_warnings()
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'disable_warnings'

Not sure why you are receiving that error.  What version of Python are you running?  However, that line will not be needed.  You can comment it out.  You may just receive some certificate warnings in the python interpreter when you execute the script.

Thanks Jake. I did end up commenting it out with no issues.

I’m on Python 2.7 and ArcMap 10.4.1. I also tried it in Pro 2.3 with whatever version of Python that uses (I’m still confused on how to switch between the two).

Searching around, it looks like the Requests module didn’t get installed with Arc Desktop until 10.5. As I do have a requests module installed, it just doesn’t have the “disable_warnings” attribute, maybe Pro 2.3 comes with a version of the module that doesn’t include this attribute?

FYI: I found the most recent “Requests” module installer on the web: ; I just haven’t gotten IT to install it yet to test. I don’t see “disable_warnings” in the TOC for the module, though. Stack Overflow says urllib3 is not part of the requests module anymore, as of the 2017 revision (>=2.16.0):

Joe Bryant

GIS Coordinator


direct 530.761.0226

Is there a way to center to image in the popup?

Hi Jake, apologies if this has been asked before but I'm having trouble with using the script with ArcGIS Server. I believe the problem is my Portal Server URL, but not sure what to adjust to fix it. Is it because I'm using a web adaptor URL? Here is a screenshot of my inputs and error message: 


Shelby Roberson‌ yes, you will need to go around the web adaptor by specifying the Fully Qualified Domain Name and port 7443.  Ex:

Hi Jake,

I can't get this tool working for Portal for ArcGIS 10.7.1 as I am stumbling upon some token errors:

Peter Goedbloed‌ if you copy the URL referenced in the error (i.e. and place it in a web browser from your client machine, does it resolve successfully?  Ex:

@JakeSkinner ‌, i'm having the identical issue @SamanthaGriffore is having and haven't been able to resolve the issue. 

I've added you to a group with the same title as this post.  the servicelayer in question should be shared to you in there.

Error message:




@TimSolomonsonyou need to enable editing on the Feature Service.  You can do this by going to the Settings.

Working like a charm in ArcPro 2.7. What are your thoughts on displaying a pdf in pop up rather than JPEG? Any foreseeable, additional configuration required? Thank you for this sweet script, moreover maintaining this forum over the years. Great work. @JakeSkinner 

@MatthewWithumI haven't tested a PDF, but it should work the same as a JPG.

Hi Jake,


what If we overwrite the feature layer? should we setup this again in the web map?

@RawanSalehyes, if you overwrite the layer the field that contains the URL will most likely be blank, so you will have to re-execute the tool to populate it.

Version history
Revision #:
1 of 1
Last update:
‎12-14-2015 08:10 AM
Updated by: