I'm building a image gallery component in NextJS, and I want the images provided to render with the original dimensions, say if an image is 300x300, the image will render 300x300, and if the image is 200x250, it will render 200x250.
I want to use the NextJS built-in <Image />
component (because of its built-in features and optimization), but it required that I specify a dimension or use layout="fill"
. I read this post which suggests using layout="fill"
, but the problem is that the image will still render in its container's size, not in its own size. I want the image to render just as-is. Currently I'm using the <img />
element, but NextJS keeps warning and annoying me and telling me that it's a bad choice. Is there a workaround? Should I just stick with the img
tag?
Note: I'm using dynamic images via randomly generated URLs, so I can't import them.