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).
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.