melody
melody copied to clipboard
The attrs filter doesn't add a valid empty alt attribute
Explain the problem
If an img has an empty alt passed through the attrs filter, it does not get added because the filter doesn't add attributes with empty values.
Expected Behaviour
The alt attribute should be added with an empty string as its value.
Actual Behaviour
The alt attribute does not get added.
I think the attrs filter needs to add a special case so that it adds the alt attribute even if the provided value is an empty string (which is valid and often desired).
Does <img alt="" src="..."> work?
Yes, simply adding an empty alt outside of attrs works just fine of course so it is a workaround, but attrs should really support it as it is a valid value for alt.