I am using the latest version of NextJS 10.0.9. I've got an Image that I'm trying to display, however I'm receiving the error:
Error: Image with src "https://picsum.photos/480/270" must use "width" and "height" properties or "layout='fill'" property.
As you can see here though, I do have all of those properties set:
<div className="card-img">
<Image
alt={media?.title}
title={media?.title}
src={media?.previewImage || 'https://picsum.photos/480/270'}
width={480}
height={270}
layout="fill"
/>
</div>
For some reason, it appears that having a default external image doesn't want to play nicely with the Image component. Does anyone know a workaround or reason why this might be the case?
A little side note too: I've got a Typescript error on the layout
property that says "Type '"fill"' is not assignable to type '"fixed" | "intrinsic" | "responsive" | undefined'.". I'm not sure if that's related?
layout="fill"
, and applying height/width to the parent div. The other thing that made this work is I noticed you using theobjectFit="cover"
property. Thanks again! – Lieu