I had the same weird classes being added on my images in wordpress.
I fought this for almost an hour, and I realized it had nothing to do with wordpress eventually. I have the Ad Block Plus extension installed on FireFox and this was my problem. I had a class names “ad-space” and add block plus automatically hid the page item.
I had an image with alt=”ad” and it wouln’t show, I has a dic with class=”ad-space” also wouldnt show.
I had the same weird classes being added on my images in wordpress.
Hopefully this saves someone a future headache.