Picture is currently not displaying within a NextJS element

A question arises in my Firebase web app regarding the NextJS component below:

import Link from "next/link";
import Image from 'next/image'
import "./displayShop.css";
import telImg from '../images/Telephone.png';


export default function DisplayShop(
  {name,phone,address,web_site,food_type}:
  {name:string,phone:string,address?:string,
    web_site?:string,food_type?:string}) {
    
  return (
    <div className='Card'>
      <div className='RNT'>
        <div className='RN'>{name}</div>
        <div className='RT'>{phone}</div>
        <a href={`tel:${phone}`} className='telIcn'>
          <Image
            className='img'
            src={telImg}
            alt="Telephone-Clip"
            width={70}
            height={70} />
        </a>
      </div>
      <div className='RTS'>
        {address &&
          <div className='RA'>{address}</div>
        }
      </div>
      {food_type &&
        <div className='RF'>{food_type}</div>
      }
      {web_site &&
      <div>
        <Link className='RW' href={web_site}
              target='_blank'>{web_site}</Link>
      </div>
      }
    </div>
  )
} /* End of ShowData */

An issue has been identified where only the alt text of the Image component (Telephone-Clip) is visible and not the actual image. Can anyone shed light on why this might be happening?

Furthermore, how can this problem be resolved effectively?

For further context, the following errors are being displayed in the browser's Web Developer Tools console:

GET
https://myapp.web.app/_next/image?url=/_next/static/media/Telephone.04133dbb.png&w=96&q=75
[HTTP/3 404  123ms]

GET
    https://myapp.web.app/_next/image?url=/_next/static/media/Telephone.04133dbb.png&w=96&q=75
Status
404
VersionHTTP/3
Transferred2.61 kB (6.68 kB size)
Referrer Policystrict-origin-when-cross-origin
Request PriorityLowest
DNS ResolutionSystem

Answer №1

When you see an HTTP 404 error in your browser, it means that the image cannot be found. It seems like the image is not located in the public folder based on the import path provided, which makes the image inaccessible to the browser or web.

To resolve this issue, you can move the image to the public folder directly (not inside a subfolder) and update the Image src attribute accordingly:

<Image className="img" src="/Telephone.png" alt="Telephone-Clip" width={70} height={70}/>

The src path should start from the public folder (assuming you have set a / at the beginning) and there is no need for the import statement.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting: Unable to Open Page with Google Material Button in Angular 5

Currently, I'm facing an issue with a button that is not opening to a new site despite following what seems like simple steps. <button mat-raised-button href="https://www.google.com/" color="primary">Connect with Stripe</button> I even a ...

Exploring how to retrieve data using a fetch query within a React component

I am currently using jest to write tests for fetching and posting data from a react page. I have written a test but I'm uncertain about how to ensure that the correct data is passed through the specific component. The test in question looks like this ...

Error TS2304: Unable to locate the word 'InputEvent'

While exploring the topic of whether TypeScript has type definitions for InputEvent, I experimented with using @types/dom-inputevent in my Angular 7 project. However, I kept encountering the error TS2304: Cannot find name 'InputEvent' whenever I ...

What is the best way to send two separate properties to the selector function?

My selector relies on another one, requiring the userId to function properly. Now, I want to enhance the selector to also accept a property named "userFriend". However, there seems to be an issue with passing this new parameter, as it only recognizes the ...

What is the best way to incorporate an automatic scroll to the following section on a single page website

My goal is to implement a feature that enables automatic scrolling between sections as the user scrolls up or down. The smooth transition should occur when the user reaches halfway through each section, seamlessly moving to the next screen on the same page ...

Transmit information from an IONIC 3 application to a PHP server using the POST method

Having trouble sending data from Ionic 3 to php via the http library using post? When php tries to retrieve it, it's unable to locate. Below is the Typescript file that generates the token to be sent to php and calls the php file on localhost (xampp) ...

Encountering an undefined error while attempting to retrieve an object from an array by index in Angular

Once the page is loaded, it retrieves data on countries from my rest api. When a user selects a country, it then loads the corresponding cities for that country. Everything is functioning properly up to this point, however, upon opening the page, the city ...

I am currently experiencing an issue where my MongoDB database connection does not automatically reopen after being

I've been working on setting up an Authentication system using NextAuth in my Next.js app. I decided to use NextAuth Credentials as the provider along with a custom login screen. Currently, I am utilizing NextAuth v.4 for this setup. In the past, I ...

Using a static class reference as a parameter in a generic type leads to a error

Before I submit a ticket on github, I want to double-check that I'm not making any mistakes. The issue should be clear enough: class A {} class B { static A = A; } function foo<T>(arg: T) {} // this is valid const b = new B.A; // "B" only ...

I'm looking to include a Loading feature within the parent tag of the ternary operator in React

I am looking to showcase the outcome of a ternary operator right after the loading message is displayed, prior to the calculation of the ternary operator. Currently, the sequence follows as such: Loading message appears, followed by the output of 'tw ...

Dynamic module declaration - Typescript 3.5

In TypeScript, I am able to declare a module like this: declare module '*.svg' { const content: string export default content } After declaring the module, I can import it using import svg from './src/file.svg' without encount ...

"Is it possible in Typescript to set the parameters of a returning function as required or optional depending on the parameters of the current

I am currently exploring Typescript and attempting to replicate the functionality of styled-components on a smaller scale. Specifically, I want to make children required if the user passes in 'true' for the children parameter in createStyledCompo ...

What is the best way to detect object changes in typescript?

Having an object and the desire to listen for changes in order to execute certain actions, my initial approach in ES6 would have been: let members = {}; let targetProxy = new Proxy(members, { set: function (members, key, value) { console.log(k ...

Guide on sending server action form data to API request in Next.js

I'm currently working on a way to send form data to a fetch request using Server actions in Next.js 14. However, I've encountered an issue where the formData.get('code') doesn't appear to be reaching its destination and instead, I ...

What is the best way to set up secure client routes?

Welcome to my College Dashboard Project! :) I am currently utilizing Next.js to create a comprehensive dashboard system for Teachers, Students, and Administrators. The Home page serves as the central hub for logging in or signing up as any of the mention ...

Combining component attributes with a mixin in Vue 2 using TypeScript

In my Vue + TypeScript project, we are utilizing Vue class components. Recently, I moved one of the component's methods to a separate mixin that relies on the component's properties. To address TypeScript errors regarding missing properties in th ...

Issue: Unable to assign value to 'googleUri' property of null. Resolving with Interface for two-way binding?

Can anyone help me figure out why I keep getting a 'set property of null' error while attempting 2way binding in my interface? Whenever I submit the form and trigger the onSave function, I encounter the error "Cannot set property 'googleUri ...

Exploring Realtime Database Querying with Firebase 5.0

I'm struggling to retrieve all the data from my RTD and store it in an array for iteration. The code below is returning 'undefined'. What could be the issue? export class AppComponent { cuisines$: Observable<any[]>; cuisines: any[ ...

What causes an error when trying to pass an object containing a file path for an image and applying it to the bg-[url()] property in Tailwind CSS?

https://i.stack.imgur.com/XeaC0.png https://i.stack.imgur.com/MxL3K.png The picture is dynamically adjusting itself upon loading. Additionally, I am interested in learning an alternative method of using the next.js Image tag to set the background and add ...

What is the purpose of importing a module in app.module.ts? And what specifically happens when importing classes one by one in the

I am interested in creating an Angular form, but I have a question about why we import 'ReactiveFormsModule' in app.module. Additionally, I am curious as to why we need to explicitly import classes like FormControl and FormGroup again in the temp ...