8

In ArcGIS Online popups how does one display attached images inline as an image instead of just a link? In case of multiple images I'm okay with just first one showing inline.

Under "Configure Popup" checking " Show feature attachments as links" results in text-only links. If the "Pop-up Media" control is used to add an image, it shows inline, however one has to know the URL ahead of time. The drop down selector does not show attachments as a possibility.

Showing attached images as text only links

Attachment attribute not listed

Desired result

Popup showing 1st image inline, hidden beneath fold are rest of attachments as links.

popup showing 1st image inline

3

6 Answers 6

4

Going through the same difficulty, I found a semi-automated solution that works as following:

  1. The popup is opened and the attachment urls load and appear as links.
  2. A placeholder image (an arrow in my case) is loaded where the image will soon load.
  3. Clicking the placeholder retrieves the url from the attachment link and replaces its own source url with the retrieved url, making the attachment image show.

To make it work, put the following values in the popup image configuration:

  • URL: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAHCAIAAABV+fA3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADJJREFUeNpi+I8KFi1aBGczMWCAxYsXQxhY5ODS2OUg0jjlYmNjmXBJYDcTIgEEAAEGAGysItsbwoS/AAAAAElFTkSuQmCC (this is just an inline image of an arrow: you can replace it with any other url.
  • Link: javascript:void(document.getElementsByClassName("esriViewPopup")[0].getElementsByTagName("img")[0].src = document.getElementsByClassName("esriViewPopup")[0].getElementsByTagName("a")[0].href); this makes the link run a javascript code that makes the (first) attachment link become the image's URL.

Hope this helps.

2
  • how can I do this without a dev edition web app.
    – NULL.Dude
    Feb 8, 2018 at 13:54
  • 1
    Great idea but possibly something has changed since 2016 -- I get "BLOCKED" messages. Mar 29, 2021 at 17:30
4

Another alternative is to use the new Operations Dashboard and add your web map to it. Pop-ups in the dashboard map will display all the images attached to a feature by default like in the image below:

enter image description here

2
  • 1
    THANKS -- I made an Operations Dashboard in ArcGIS Online but keep my data in ArcGIS Enterprise. I don't have to manage more storage online and allows me to make the AGOL app open to the public so I don't have to maintain separate user accounts; Users are prompted to use their AGE accounts to get the feature layer to load. Mar 29, 2021 at 17:27
  • Not sure if it would make sense to mark this as the answer but it is the best workaround.
    – cbunn
    Mar 30, 2021 at 18:17
2

I guess a potential workaround that would add a couple steps to your workflow would be the following:

  1. Add text field [ATTACH_URL] (255 char) to the attribute table of the feature layer
  2. Create a new point and upload the attachment
  3. Click on the popup, then right-click and ‘Copy link address’ from the link to the attachment
  4. Edit the feature, and paste this URL into the [ATTACH_URL] field enter image description here
  5. Configure the popup, and under Pop-up Media, click ADD>Image
  6. Configure the popup as the following: enter image description here

You would then have to repeat steps 3-4 every time you publish a new feature.

Not ideal or automated, but possible.

2
  • thanks for a workaround. Like you say, not ideal but possible. There's got to be a way to get at the system attribute. ...Closest geonet thread: geonet.esri.com/message/544252#544252 (also unanswered) Sep 11, 2015 at 17:24
  • You can automate most of this via attribute expressions, save for retrieving the attachment info, which has to be a field calculate. At least it's only 1 quick manual step when features are added, which could be further automated via an attribute rule.
    – BlueTalon
    Dec 15, 2022 at 8:46
1

Here is a helpful GP tool that will add attachments to a pop-up:

https://geonet.esri.com/docs/DOC-7445

2
  • Please, don't post a link-only answer. Links can be lost in a future. You can add steps or highlights in your answer
    – aldo_tapia
    Sep 26, 2017 at 12:06
  • Hi Jake, please take a look here
    – bummi
    Nov 17, 2017 at 16:22
1

The best way to do this is to use the "Pop-up Media" option under the "configure Pop-up" dialog within ArcGIS online for the layer you want to work with.

For the URL config you want to substitute 2 parts of the URL with {OBJECTID} like this bellow :

https://your.portal.url/server/rest/services/service_folder/service_name/MapServer/0/{OBJECTID}/attachments/{OBJECTID}?

This should give you the nice clean output you are expecting.

4
  • If you try this, I suggest using a different field, objectIDs are notoriously unstable.
    – JMers
    Jun 11, 2019 at 16:39
  • I think you'd need to set up a field, I tested it with OBJECTID and it does not work for me in AGOL or AGE or WABDE.. Mar 29, 2021 at 17:43
  • The last segment is the ATTACHMENT ID, not the OBJECT ID e.g. if you had 2 attachments per feature, the urls for feature 3's attachments would be ../MapServer/0/3/attachments/5 and /6 You have to retrieve the attachment ID using arcade: Attachments($feature) in a field calculate or attribute rule (not supported in attribute expressions currently).
    – BlueTalon
    Dec 15, 2022 at 5:29
  • @JMers it is best to avoid using OBJECTID as a unique identifier for features in analysis due to edits potentially reordering features and subsequently OBJECTID, but the feature ID segment of the above URL must match the index of the feature in the layer, which OBJECTID inherently represents.
    – BlueTalon
    Dec 15, 2022 at 8:51
0

If your layer is hosted in AGOL, you can now use the map viewer beta and select the gallery option for attachments under configure pop-up.

This option is currently disabled for enterprise/portal hosted layers. An ideal workaround is to create a web app with the attachment viewer template.

If you're on an older version of enterprise (as we are) there is a bug where an attachment viewer app doesn't honour image orientation. The workaround I've developed, which may be useful to others in similar circumstance, is:

Calculate a field (using arcade) including comma-separated attachment IDs:

//calculate the attach IDs field
function IDs(f){
    return f.ID;
}

var Attach_ = Attachments($feature);
var AttachIDs = Map(Attach_, IDs);
return Concatenate(AttachIDs,','); 

This must be a field CALCULATE as attribute expressions do not currently support the Attachments function. I believe an attribute rule may also work.

Once the above is available, you can add attribute expressions in your pop-up (1 per attached image) as:

//build the URL for image attachment <ImageNumber>
var ImageNumber = 0
var AttachIDs = split($feature.AttachmentIDs,',')

if(ImageNumber > count(AttachIDs) - 1)
    return ''

var AttachID = AttachIDs[ImageNumber]
var BaseURL = "<your_domain>/server/rest/services/Hosted/LayerName/FeatureServer/0/"
var ObjectID = $feature.OBJECTID
return BaseURL + ObjectID + "/attachments/" + AttachID

ImageNumber must be incremented for each expression, starting from 0.

After that you can add an image per attachment as pop-up media, referencing the matching attribute expression for the url and link fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.