perf: fix sizes attribute scaling bug to prevent mobile devices from downloading 1920w desktop images
This commit is contained in:
@@ -136,7 +136,7 @@ export default async function Home(props: { params: Promise<{ locale: string }>
|
|||||||
as: 'image',
|
as: 'image',
|
||||||
fetchPriority: 'high',
|
fetchPriority: 'high',
|
||||||
imageSrcSet: '/assets/videos/web/hero-kabelpflug-poster-mobile.webp 800w, /assets/videos/web/hero-kabelpflug-poster.webp 1920w',
|
imageSrcSet: '/assets/videos/web/hero-kabelpflug-poster-mobile.webp 800w, /assets/videos/web/hero-kabelpflug-poster.webp 1920w',
|
||||||
imageSizes: '(max-width: 768px) 800px, 1920px'
|
imageSizes: '100vw'
|
||||||
});
|
});
|
||||||
|
|
||||||
const mdx = await getMdxContent(locale, 'home');
|
const mdx = await getMdxContent(locale, 'home');
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export function HeroVideo(props: HeroVideoProps) {
|
|||||||
key={`img-${pathname}-${posterSrc}`}
|
key={`img-${pathname}-${posterSrc}`}
|
||||||
src={posterSrc}
|
src={posterSrc}
|
||||||
srcSet={posterSrc.includes('-poster.webp') ? `${posterSrc.replace('-poster.webp', '-poster-mobile.webp')} 800w, ${posterSrc} 1920w` : undefined}
|
srcSet={posterSrc.includes('-poster.webp') ? `${posterSrc.replace('-poster.webp', '-poster-mobile.webp')} 800w, ${posterSrc} 1920w` : undefined}
|
||||||
sizes={posterSrc.includes('-poster.webp') ? "(max-width: 768px) 800px, 1920px" : undefined}
|
sizes={posterSrc.includes('-poster.webp') ? "100vw" : undefined}
|
||||||
alt={posterAlt}
|
alt={posterAlt}
|
||||||
className="absolute inset-0 w-full h-full object-cover z-[1] pointer-events-none"
|
className="absolute inset-0 w-full h-full object-cover z-[1] pointer-events-none"
|
||||||
decoding="sync"
|
decoding="sync"
|
||||||
|
|||||||
Reference in New Issue
Block a user