Skip to content

Commit

Permalink
feat(image): allow explicit empty string of alt attribute for accessi…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
Arukuen committed Dec 3, 2024
1 parent d2d3215 commit a67e1f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/block-components/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a67e1f5

Please sign in to comment.