Skip to content

Commit e5126f9

Browse files
fix(gatsby-source-wordpress): Set empty default alt tag for inline images (#38341)
set empty string as fallback Co-authored-by: Tyler Barnes <[email protected]>
1 parent 668aa5f commit e5126f9

File tree

1 file changed

+4
-2
lines changed
  • packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes

1 file changed

+4
-2
lines changed

packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/process-node.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,8 @@ export const replaceNodeHtmlImages = async ({
670670
) {
671671
gatsbyImageHydrationData = {
672672
image: imageResize,
673-
alt: cheerioImg?.attribs?.alt,
673+
// Wordpress tells users to leave "alt" empty if image is decorative. But it returns undefined, not ``
674+
alt: cheerioImg?.attribs?.alt ?? ``,
674675
className: `${
675676
cheerioImg?.attribs?.class || ``
676677
} inline-gatsby-image-wrapper`,
@@ -686,7 +687,8 @@ export const replaceNodeHtmlImages = async ({
686687
`img`,
687688
{
688689
src: publicUrl,
689-
alt: cheerioImg?.attribs?.alt,
690+
// Wordpress tells users to leave "alt" empty if image is decorative. But it returns undefined, not ``
691+
alt: cheerioImg?.attribs?.alt ?? ``,
690692
className: `${
691693
cheerioImg?.attribs?.class || ``
692694
} inline-gatsby-image-wrapper`,

0 commit comments

Comments
 (0)