Optimize lekte component

This commit is contained in:
2026-04-16 13:55:20 +04:00
parent 32a0abae65
commit 1373e80d34
+11 -3
View File
@@ -137,6 +137,14 @@ export default function Lekte({audio, url, parole}) {
audioRef.current.volume = value / 100 audioRef.current.volume = value / 100
} }
const imagePath = parole?.couverture?.data?.attributes?.formats?.thumbnail?.url
const width = parole?.couverture?.data?.attributes?.formats?.thumbnail?.width || 192
const height = parole?.couverture?.data?.attributes?.formats?.thumbnail?.height || 192
const imageSrc = imagePath
? new URL(imagePath, IMAGE_URL).toString()
: '/logo-192x192.png'
return ( return (
<Box sx={{width: '80%', position: 'relative', zIndex: 0}}> <Box sx={{width: '80%', position: 'relative', zIndex: 0}}>
<Widget> <Widget>
@@ -144,9 +152,9 @@ export default function Lekte({audio, url, parole}) {
<CoverImage> <CoverImage>
<Image <Image
alt={parole.titre} alt={parole.titre}
src={parole?.couverture?.data?.attributes?.formats?.thumbnail ? `${IMAGE_URL}${parole.couverture.data.attributes.formats.thumbnail.url}` : '/logo-192x192.png'} src={imageSrc}
width={parole?.couverture?.data?.attributes?.formats?.thumbnail ? parole.couverture.data.attributes.formats.thumbnail.width : 192} width={width}
height={parole?.couverture?.data?.attributes?.formats?.thumbnail ? parole.couverture.data.attributes.formats.thumbnail.height : 192} height={height}
/> />
</CoverImage> </CoverImage>
<Box sx={{ml: 1.5, minWidth: 0}}> <Box sx={{ml: 1.5, minWidth: 0}}>