Skip to content

Commit

Permalink
Gallery block: use image caption as fallback for alt text. (#26082)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed Oct 18, 2020
1 parent 8219e43 commit 9ed837b
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions packages/block-library/src/gallery/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,17 @@ export default function save( { attributes } ) {
href = image.link;
break;
}
// The image should only have an aria-label if it's within a link and has no alt text.
const imageLabel =
! image.alt && image.caption && href
? image.caption
: null;

const img = (
<img
src={ image.url }
alt={ image.alt }
alt={ image.alt !== '' ? image.alt : image.caption }
data-id={ image.id }
data-full-url={ image.fullUrl }
data-link={ image.link }
className={
image.id ? `wp-image-${ image.id }` : null
}
aria-label={ imageLabel || null }
/>
);

Expand Down

0 comments on commit 9ed837b

Please sign in to comment.