I think this could be done as an emacs plugin. Emacs already has a mode that
allows you to see paths to images as the image themself in the editor.
[iimage.el](https://github.com/typester/emacs/blob/master/lisp/iimage.el) is
the [*mode* (emacs
term)](https://www.gnu.org/software/emacs/manual/html_node/emacs/Minor-Modes.html#Minor-Modes)
that controls the behavior of it. If you understand it, I think you can create
a _mode_ on your own that does exactly what you want. Or you find a way how
this general solution applies to help your problem.