diff --git a/packages/contentful/cypress/component/ContentfulVisual.cy.tsx b/packages/contentful/cypress/component/ContentfulVisual.cy.tsx index c548a61..ffa7e3b 100644 --- a/packages/contentful/cypress/component/ContentfulVisual.cy.tsx +++ b/packages/contentful/cypress/component/ContentfulVisual.cy.tsx @@ -113,4 +113,32 @@ describe('contentful visual entry props', () => { .should('contain', videoAsset.url) }) + it('finds alt on src image', () => { + cy.mount( + + ); + cy.get("img").invoke("attr", "alt").should("eq", "Landscape gradient"); + }) + + it("finds alt on src video", () => { + cy.mount( + + ); + cy.get("video") + .invoke("attr", "aria-label") + .should("eq", "Background loop description"); + }); + }) diff --git a/packages/contentful/src/ContentfulVisual.tsx b/packages/contentful/src/ContentfulVisual.tsx index 48acf8f..ac0ef45 100644 --- a/packages/contentful/src/ContentfulVisual.tsx +++ b/packages/contentful/src/ContentfulVisual.tsx @@ -55,7 +55,14 @@ export default function ContentfulVisual( responsiveAspectCalculator : getImageAspect(image || src?.image || src?.portraitImage) )} - alt={ alt || src?.alt || makeAssetAlt(image) || makeAssetAlt(video)} + alt={ + alt + || src?.alt + || makeAssetAlt(src?.image) + || makeAssetAlt(image) + || makeAssetAlt(src?.video) + || makeAssetAlt(video) + } /> ) }