Skip to content

Commit

Permalink
Merge pull request #59 from BKWLD/fix-video-only-contentful-visuals
Browse files Browse the repository at this point in the history
Fix video only contentful visuals
  • Loading branch information
weotch authored Nov 20, 2024
2 parents b5ec182 + 1cb6a0e commit 388ea1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/contentful/cypress/component/ContentfulVisual.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ describe('contentful visual entry props', () => {
portraitVideo: null,
}} />)

// There should be no vidoes rendered
cy.get("video").should("not.exist");

// Portrait asset
cy.get('img').hasDimensions(VW, VW)
cy.get('img').its('[0].currentSrc')
Expand All @@ -84,6 +87,9 @@ describe('contentful visual entry props', () => {
portraitImage: null,
}} />)

// There should be no imgs rendered
cy.get('img').should('not.exist')

// Portrait asset
cy.get('video').its('[0].currentSrc')
.should('contain', portraitVideoAsset.url)
Expand Down
3 changes: 3 additions & 0 deletions packages/contentful/src/lib/urlBuilding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const defaultImageLoader: ImageLoader = ({
src.portraitImage.url :
src.image?.url || src.url

// If no URL found, return nothing
if (!url) return ''

// Make Contentful resizing instructions
const query = new URLSearchParams({ w: String(width) })

Expand Down
1 change: 1 addition & 0 deletions packages/react/src/PictureImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function PictureImage(props: PictureImageProps): ReactNode {

// Make the img src url
const srcUrl = makeSrcUrl(src, imageLoader)
if (!srcUrl) return null

// Make array or props that will be used to make <source>s. A `null` type is
// always added to create fallback sources for native mime-type of the
Expand Down

0 comments on commit 388ea1b

Please sign in to comment.