wow, indeed first time I’m hearing someone using so many attachments… you’re stressing xwiki to the max (good!)
Sure it’s interesting. I wouldn’t call it vital but certainly a nice to have. Note that this can be developed as an extension of XWiki and it doesn’t need to be in the core for you to have it.
It’s actually quite easy to write a small script to do this on the current page. You don’t even need a query for that. You can simply get the XDOM of the page. It returns your page content as structured content with Paragraph Blocks, Space Blocks, Link Blocks, etc. So it’s very easy to iterate over all found Links or Images and verify if the reference is local or not.
You could check https://rendering.xwiki.org/xwiki/bin/view/Main/GettingStarted#HExamples to see some examples which you could use in Groovy. To get the xdom of the page:
def xdom = xwiki.getDocument('reference to my doc').xdom
Now you don’t need this and a simple search would be enough for your use case probably:
#set ($content = $xwiki.getDocument('reference to my doc').content)
## get attachments, see https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Scripting/APIGuide/#HListallattachmentsofapage