Is it the line break that’s causing the issue? That would be my guess. You will need to remap those BBCodes to remove the line break. Replace a string in all posts should be helpful.
Maybe convert them to HTML comments for now? You could later replace them with the stored images.