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:
@@ -50,7 +50,7 @@ export const ImageMedia: React.FC<MediaProps> = (props) => {
|
|||||||
src = `${getClientSideURL()}${url}`
|
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
|
// NOTE: this is used by the browser to determine which image to download at different screen sizes
|
||||||
const sizes = sizeFromProps
|
const sizes = sizeFromProps
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const ImageMedia: React.FC<MediaProps> = (props) => {
|
|||||||
src = `${getClientSideURL()}${url}`
|
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
|
// NOTE: this is used by the browser to determine which image to download at different screen sizes
|
||||||
const sizes = sizeFromProps
|
const sizes = sizeFromProps
|
||||||
|
|||||||
Reference in New Issue
Block a user