Skip to content

Commit

Permalink
fix(templates): prevent image priority and lazy loading incompatibili…
Browse files Browse the repository at this point in the history
…ty (#10023)

This PR fixes an issue in the hero banner of website templates where
`priority` was passed to `ImageMedia` component but was incompatible with
NextImage `loading="lazy"`, causing error. The fix is to add a ternary
condition to check if `priority` prop is passed before setting `loading.
  • Loading branch information
hkn-wt authored Dec 17, 2024
1 parent 29ad1fc commit 7037983
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ImageMedia: React.FC<MediaProps> = (props) => {
src = `${getClientSideURL()}${url}`
}

const loading = loadingFromProps || 'lazy'
const loading = loadingFromProps || (!priority ? 'lazy' : undefined)

// NOTE: this is used by the browser to determine which image to download at different screen sizes
const sizes = sizeFromProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ImageMedia: React.FC<MediaProps> = (props) => {
src = `${getClientSideURL()}${url}`
}

const loading = loadingFromProps || 'lazy'
const loading = loadingFromProps || (!priority ? 'lazy' : undefined)

// NOTE: this is used by the browser to determine which image to download at different screen sizes
const sizes = sizeFromProps
Expand Down

0 comments on commit 7037983

Please sign in to comment.