fix(templates): prevent image priority and lazy loading incompatibility (#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.
This commit is contained in:
Hugo Knorr
2024-12-17 15:56:53 +01:00
committed by GitHub
parent 29ad1fcb77
commit 7037983de0
2 changed files with 2 additions and 2 deletions

View File

@@ -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

View File

@@ -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