There was an issue with VisualEditor handling of media links. It has been discussed and solved in T198511. There is a patch into master [1] from 6 month ago, that has also been merged to REL1_32 [2]. I am experiencing the same issue on a REL1_31 (LTS) wiki. I have cherry-picked that change to REL1_31 now: https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/VisualEditor/+/534274/
Unfortunately the CI tests break. But to me it looks like this is unrelated to the change. Can somebody please review and merge that change to REL1_31 and help me to understand the CI errors?
[1] https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/VisualEditor/+/454860/
[2] https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/VisualEditor/+/497354/