Force Images without defined alt text to be Alt=""

Hello -

To be compliant with current accessibility standards, we need images that are purely decorative to display alt="". The alt text must be there but the value needs to be null (i.e. alt="").

I found another thread that was getting at this, and I’ve tried the following filter but it isn’t working for me. Is there a simple way for me to do something like this so that the alt text for images show alt="""?

add_filter( 'cs_fallback_alt_text', function($text) {
  return '';
} );
1 Like

Hello @j0hnwat3rman,

Thanks for writing to us.

In case you want to display Alt text of the image through the Image element, I would suggest you please have a look at this thread to learn more about how to display the alt text.

Hope it helps
Thanks

I appreciate the response, but that’s not at all what I am after.

I have images that are purely decorative. The default alt text for images in pro is “image” but that’s not going to work for the accessibility standards required for this site. Accessibility standards say that images that are decorative shouldn’t have alt text, but it’s also important that the alt text have a value of null, rather than having nothing at all.

So, if I add an image element via cornerstone, I want to be able to leave the alt-text value blank, but I need that value to look like alt="" to screen readers.

The filter I noted earlier is something I found on this thread. It would work just fine if I needed to replace Pro’s default alt=“image” with another word, but I need the default alt text for images to specifically be alt=""

Hey @j0hnwat3rman,

Just add a priority to your custom function. Update your PHP code and use this instead:

add_filter( 'cs_fallback_alt_text', function($text) {
  return '';
}, 10);

Be advised that custom coding is beyond the scope of our support under our Support Policy. If you are unfamiliar with code and resolving potential conflicts, you may select our One service for further assistance.

Kindly let us know how it goes.

Thanks, Ruenel.

Unfortunately, that didn’t seem to do the trick.

From what I can tell, the filter requires something in the return value for it result in alt text being displayed.

Hey @j0hnwat3rman,

As my colleague said, providing custom code is outside the scope of our theme support. You may seek 3rd party developers to help you with your problems or you can avail One where we can answer questions outside of the features of our theme.

Thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.