Skip to content

Commit a67e1f5

Browse files
committed
feat(image): allow explicit empty string of alt attribute for accessibility
1 parent d2d3215 commit a67e1f5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/block-components/image/image.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ const Image = memo( props => {
269269
onError={ () => setHasImageError( true ) }
270270
className={ imageClasses }
271271
src={ src || undefined }
272-
alt={ striptags( props.alt || undefined ) }
272+
alt={ striptags( props.alt || '' ) }
273273
title={ striptags( props.title || undefined ) }
274274
width={ props.width || undefined }
275275
height={ props.height || undefined }
@@ -438,10 +438,10 @@ const ImageContent = props => {
438438
: undefined
439439

440440
const propsToPass = {}
441-
const alt = striptags( props.alt || undefined )
442-
if ( alt ) {
443-
propsToPass.alt = alt
444-
}
441+
442+
// Allow explicit empty string for accessibility
443+
propsToPass.alt = striptags( props.alt || '' )
444+
445445
const title = striptags( props.title || undefined )
446446
if ( title ) {
447447
propsToPass.title = title

0 commit comments

Comments
 (0)