Disable default "Image" alt text?

I’ve tried this:

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

and

add_filter( 'cs_fallback_alt_text', '__return_empty_string' );

based on this help article, but this removes alt completely from the image element.

For EAA we must comply with having alt on images, even if they are decorative (which, if decorative, must still have an empty alt tag).

This currently seems to be impossible… but I’m hoping someone has a solution. I simply want to leave the alt text box blank in Cornerstone and expect a blank alt attribute in my image.

1 Like

Hey Scott,

Thanks for writing in! Instead of displaying an empty string, try adding a Space character:

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

Hope this helps.

Oh sorry for the confusion, I need a blank alt tag, not a space. Even with a space it flags on WAVE

We have a “Decorative” control for our Image element just for this. I believe it just removes the Alt tag. Is the correct accessibility to have the alt tag be empty and not removed?

According to what I’ve found on w3.org, two things need to be in effect for an image to be purely decorative:

  1. the title attribute is either absent or empty
  2. the alt attribute is present and empty

It would be nice if the “decorative” switch did these two things, as they’re important for accessibility.

In the meantime, is there any way to set the default alt on images to simply be alt=""?

Hi Scott,

Regretfully, there is no option to set alt="" as you are expecting. But you can try with the do_shortcode_tag filter and replace the alt="Image" which is a default when no value is set in the field.

Thanks

There has to be a function that sets the alt text to “Image” by default, right? Inside of Cornerstone or Pro? And if so, couldn’t there be an override to that specific function? Something that could be placed in functions.php? To me, if I leave a field blank, I expect it to be blank, not filled with something that causes more headaches than it solves.

Thank you for the info. For now, you can keep the Decorative option off, then add a single space in the Alt field to keep it blank empty instead of showing the default “Image” text. We’ll forward the issue to our channel.

Ismael, I don’t mean to be rude, but we’ve already discussed (above) that adding a space is not an option. For accessibility, having a blank alt attribute is just as bad as having an improper one like “Image”.

I was able to work with AI to get a temporary fix, which I’ll include below:

// Override the fallback alt text to be an identifiable marker
add_filter( 'cs_fallback_alt_text', function() {
  return '[[CS_EMPTY_ALT]]'; // marker to bypass default "Image" fallback
});

// On the frontend only, replace the marker or missing alt with alt=""
if ( ! is_admin() ) {
  add_filter( 'cs_apply_image_atts', function( $atts ) {
    if ( ! isset( $atts['alt'] ) || $atts['alt'] === '[[CS_EMPTY_ALT]]' ) {
      $atts['alt'] = '';
    }
    return $atts;
  });
}

This ensures that when the alt field is left blank in the builder, the output becomes alt="" on the front end — as required by WCAG, WAVE, and EAA for decorative images.

The fallback string “Image” (or even a space) is misleading to assistive tech (such as screen readers) and doesn’t meet compliance.

This solution I’m providing bypasses the internal fallback mechanism with a unique marker ([[CS_EMPTY_ALT]]), then swaps it out just before rendering.

It’s lightweight, doesn’t affect the builder, and keeps everything compliant until an official fix can be implemented.

Please consider adding this to the list of known issues — it’s an important fix for those of us working toward full accessibility compliance. While this workaround does the job for now, an official solution would help ensure all users, regardless of technical ability, can deliver WCAG-compliant content out of the box.

1 Like

Thanks for sharing your solution @sfreeman. I’ve added this to our list of things to review and fix.

1 Like

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