Skip to content

Commit

Permalink
fix(gatsby-source-wordpress): Set empty default alt tag for inline im…
Browse files Browse the repository at this point in the history
…ages (#38341)

set empty string as fallback

Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
  • Loading branch information
LekoArts and TylerBarnes committed Jul 6, 2023
1 parent 668aa5f commit e5126f9
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ export const replaceNodeHtmlImages = async ({
) {
gatsbyImageHydrationData = {
image: imageResize,
alt: cheerioImg?.attribs?.alt,
// Wordpress tells users to leave "alt" empty if image is decorative. But it returns undefined, not ``
alt: cheerioImg?.attribs?.alt ?? ``,
className: `${
cheerioImg?.attribs?.class || ``
} inline-gatsby-image-wrapper`,
Expand All @@ -686,7 +687,8 @@ export const replaceNodeHtmlImages = async ({
`img`,
{
src: publicUrl,
alt: cheerioImg?.attribs?.alt,
// Wordpress tells users to leave "alt" empty if image is decorative. But it returns undefined, not ``
alt: cheerioImg?.attribs?.alt ?? ``,
className: `${
cheerioImg?.attribs?.class || ``
} inline-gatsby-image-wrapper`,
Expand Down

0 comments on commit e5126f9

Please sign in to comment.