TwicPics / components

A Web component library that brings the power of TwicPics to your favorite web framework.
MIT License
53 stars 2 forks source link

`<TwicImg>` component should not override empty strings in `alt` attributes #74

Closed tomtuv closed 9 months ago

tomtuv commented 9 months ago

At the moment, the <TwicImg> React component replaces empty strings (even when deliberately added) with the image filename in alt attributes.

An empty alt attribute indicates to assistive technologies that the image is decorative and should be ignored. It is not the same as not having the attribute at all.

I've tried to add an ARIA role of presentation to the component which does the same thing as an empty alt attribute but it is not added to the <img> element. It would be useful if we could pass attributes to it as well.

Also, I think the default value when no alt attribute is specified should be empty strings instead of the image filename. This is what Next.js does for example with their <Image> component. It's better to hide the image for screen readers than to let them announce it with a potentially computer-generated filename.

For reference:

mbgspcii commented 9 months ago

Hi @tomtuv

Yes, you're right.

This will be done in the next version.

I'll keep you informed.

tomtuv commented 9 months ago

@mbgspcii Great news! Thanks for your quick response.

mbgspcii commented 9 months ago

Hi @tomtuv

We have just deployed version 0.23.2, which takes into account your request concerning the alt property.

In this version, the alt default value becomes an empty string.

We've also added to our roadmap the addition of the ARIA role img to our components.

Once again, we'll keep you informed.

Hoping 0.23.2 will suit your current needs.

Regard.