I am looking for a way to replace all links on images.
Currently when a user clicks an image it links to the source file. 

What I want it to do is to ink to: example.com/editor=12&image=filename.jpg
So every <a> that encloses an <img> should link to that site with the image filename so it can be loaded in an editor.

First, I tried to replace the links with ajax, but that does not work with lazy load and also seems less practical.
The second thing I tried is to filter the $content of the post. But with that I can only replace the /wp-content/uploads/ part. 
I can’t filter for the first part (http://) which leads to also all src being replaced and no image shows up at all. 

Is there any way to do this by hooks maybe? 

Kind regards 
Patrick