Ola,
Your solution for the "src" attribute looks useful; and better than leaving it wide open. My images are all local, and reference the file with extention directly, so your solution would be good for me.
There is probably a wider design solution, but its not one I feel qualified to get involved with. In the meantime, I'd be grateful if you can make the patch available, pls?