NO BUG: Invalid alt Attribute Output on Image Elements

The builder automatically outputs syntactically invalid alt attributes for image elements (e.g., rendering alt without a value instead of alt=""). This is not valid HTML, as alt is not a boolean attribute and must always contain a value.

I made attempts to correct this behavior using both a PHP filter and JavaScript in order to enforce a proper alt="" attribute. However, neither approach was successful, as the invalid attribute appears to be injected or overridden at a later stage in the rendering process. Explicitly setting an empty alt text within the image settings also does not resolve the issue.

At this time, i cant find a viable way to correct the malformed alt attribute externally. As far as I understand this is bad from a accessibility perspective.

Hi @Jonas0815 ,

Thank you so much for reporting the issue.

Bricks is using WordPress native wp_get_attachment_image function to output the selected image.

If the image has no alt text set, it is expected to have alt='' rendered.

You can replicate this in the default WP theme by inserting an image block on a post and check the frontend HTML.

FYI:

You can set the alt text in media library, or can overwrite it within the Image element.

Regards,
Jenn

Hi, thanks for the quick reply. I now figured out that the alt tag is rendered this way by the Chrome, DevTools while the Firefox DevTools show the alt=“” correctly. My bad.