I have found a solution without using next/future/image
and with using css
with width-[100%]
on the parent div like so.
<div
className="mx-auto w-[100%] md:bg-card md:w-[720px] max-w-4/5"
key={img.imageProps.src}
>
<Image
placeholder="blur"
{...img.imageProps}
layout={'responsive'}
alt={`${chapterData.chapterNumber} image`}
/>
</div>
{...img.imageProps}
is a object that looks like this that has original height and width.
export type ImageProps = {
blurDataURL: string;
src: string;
height: number;
width: number;
type?: string | undefined;
};
You can get these image props using something like plaiceholder
, it comes loaded with blurImage
data url.
const convertImages = async (image: string) => {
const { base64, img } = await getPlaiceholder(image, { size: 14 });
return {
imageProps: {
...img,
blurDataURL: base64,
},
};
};
OR
You can create your own function to get the height
and width
for each image individually before displaying it, which is required by the next <Image/>
Hope this helps.