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.