2

My Code:

<img src={`icons/mint drop.png`} alt="drop" />
            <hr className={`${styles.smallDivider} ${styles.detailPageHr}`} />
            <p className={styles.selectBoxDescription}>
              Creator Finnez: <b></b> 
            <p className={styles.selectBoxDescription}>
              Genius artist, will bring you to the next level.
            </p> 
            </p>

Gives me a warning: Warning: Do not use <img> element. Use <Image /> from next/image instead. See: https://nextjs.org/docs/messages/no-img-element @next/next/no-img-element

I tryed the solution from the next.js docs:

<picture>
  <source src="icons\mint drop.png" type="image/png" />
  <img
   src="icons\mint drop.png"
   alt="drop"/>
</picture>

But it doesnt works! It doesnt show me the image, i can see only "drop" but no image!

2
  • Are you using the backslash (\ ) instead of /? Commented Dec 16, 2022 at 8:13
  • icons\mint drop.png -> icons/mint drop.png and you should probably also refrain from using file names with whitespaces in it ... Commented Dec 16, 2022 at 8:30

1 Answer 1

3

It's because nextjs recommended to Use next/image to improve performance with automatic Image Optimization.

Turn your image into:

<picture>
    <source src="public\icons\mint drop.png" type="image/png" />
    <Image
     src="public\icons\mint drop.png"
     alt="drop"/>
</picture>

Make sure to import Image before.

import Image from 'next/image'
Sign up to request clarification or add additional context in comments.

1 Comment

Thx man, with your help i found the solution!!! It is: <Image src="/icons/mint drop.png" alt="Landscape picture" width={220} height={220} />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.