Thanks! I’m pretty sure I tried this ages ago and it didn’t work at the time, but I tried this again now and it does the job.

The key is to keep up through "data:" since any shorter (even just dropping the ":") and it gets treated a relative link instead.