From a67e1f565e5be277019c526648ef880acceb775f Mon Sep 17 00:00:00 2001 From: Alquen Antonio Sarmiento Date: Tue, 3 Dec 2024 10:48:47 +0800 Subject: [PATCH] feat(image): allow explicit empty string of alt attribute for accessibility --- src/block-components/image/image.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/block-components/image/image.js b/src/block-components/image/image.js index ac14edb80..c03692980 100644 --- a/src/block-components/image/image.js +++ b/src/block-components/image/image.js @@ -269,7 +269,7 @@ const Image = memo( props => { onError={ () => setHasImageError( true ) } className={ imageClasses } src={ src || undefined } - alt={ striptags( props.alt || undefined ) } + alt={ striptags( props.alt || '' ) } title={ striptags( props.title || undefined ) } width={ props.width || undefined } height={ props.height || undefined } @@ -438,10 +438,10 @@ const ImageContent = props => { : undefined const propsToPass = {} - const alt = striptags( props.alt || undefined ) - if ( alt ) { - propsToPass.alt = alt - } + + // Allow explicit empty string for accessibility + propsToPass.alt = striptags( props.alt || '' ) + const title = striptags( props.title || undefined ) if ( title ) { propsToPass.title = title