prismicio-community / java-kit

Community maintained development kit for Prismic and the Java language
https://prismic.io
15 stars 38 forks source link

[bug] Image alt attribute should be "" instead of "null" when empty alternative text in CMS #57

Closed damienbeaufils closed 7 years ago

damienbeaufils commented 7 years ago

Hello team!

When you have an image in Prismic, if there is no alternative text, the alt attribute built from Fragment.Image#asHtml method is the string "null" instead of an empty string. This PR fix this behavior: when the alternative text is empty, image alt attribute is now "".

Omitting 'alt' attribute altogether indicates that the image is a key part of the content, and no textual equivalent is available. Setting this attribute to an empty string (alt="") indicates that this image is not a key part of the content, and that non-visual browsers may omit it from rendering. (see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img)

This PR depends on #56

Thanks and happy hacktoberfest!