I've written a filter to wrap images included in posts with figure tags and their captions with figcaption tags. I turned off the visual editor so that it doesn't strip out all the html from the images.
That all seems to work fine until I publish or update the post. At this point the link to the full size image gets changed to
where before it was
Can anyone help suggest why this is happening?
Here is a link to the filter code on pastebin