I believe you can achieve what you are after by using a Details element. It will render what you defined in the popup. Image attachments will render in the Details element and non-image attachments can be opened via the link.
To have the Details element show the feature(s) selected on the map, configure the map such that a selection on the layer applies a filter action to the Details element.
Note: In order for the attachments to appear in the Details element, you need to have the "Show feature attachments as links" enabled in the layer's popup within the web map (as shown below).