On French Wikipedia we have a template (it's for images in infoboxes) that produces image tags. Sometimes the image is a SVG, thus we have added a lang=fr parameter in the image tag.
Problem is, the image can also be a JPEG, PNG, etc. and with these formats, the lang parameter isn't parsed, thus the lang=fr is interpreted as an unnamed, caption parameter.
I think the lang parameter should always be parsed, even if it is not applicable and discarded afterwards.