Cannot load images from public folder - reactjs

I store images in public folder, image name is a number from 1 to Image quantity, so I can get image with
<img
ref={this.imageRef}
src={process.env.PUBLIC_URL + `/images/${this.props.index}.jpeg`}
alt={`image #${this.props.index}`}
/>
When I run it on my local npm server images are rendered correclty so I can see them, but when I try to open my gallery from my web site deployed with AWS Amplify, they are not loaded, I see only image alt and image logo.
You can check it out at https://www.diamondcoring.ru/gallery
What's wrong with it ?

I don't know why, but the problem was in file extension .jpeg - it is not handled. .jpg or .png work fine

Related

React Dropzone: Image files preview issue

I upload image file with previewing it in react dropzone. However, after uploading, the file is successfully uploaded (I can see it in console) but sometimes the image file is previewed and sometimes the same image file give error like:
GET blob:http://localhost:3000/438716d3-2317-438b-9d1e-eb7bc5e6149f net::ERR_FILE_NOT_FOUND
https://i.stack.imgur.com/AwjI9.png
I had this issue and the solution was to use URL.createObjectURL in the image src when displaying the image file from Dropzone.
e.g
<img src={URL.createObjectURL(file)} alt={file.name} />
Hopefully this helps someone else.

Can't find a reason why this image won't load on react

So there is a folder named "images" in Public.
The funny thing is it was working fine until I uploaded it on github pages, and then when I refreshed, it just broke. The images don't load either on the github pages or on local anymore.
<img src= "images/equilibrium.jpg" alt="equilibrium background" />
Just add / at the beginning of source url.
<img src="/images/equilibrium.jpg" alt="equilibrium background" />

How to use an image in react imported from localhost

So i'm working on a react project and i want to use an image which is stored in my computer
i made the following code
<img src='my_image.png'/>
however it doesn't show in the browser as shown below
see image
upload your images in your public folder then access it
eg:public/images/p1.png
<img src='images/p1.png'/>
https://codesandbox.io/embed/amazing-bouman-x3mnr?fontsize=14&hidenavigation=1&theme=dark

How to set the nuxt assets url after build

Hello every i am having issue after deploying the nuxt app to subdirectory, now the assets are not found here is the screen shot, the red border represent the assets url
You have to put the image in the assets folder, then you can load your image with:
<img src="~/assets/my_image.jpg" />

image path in ng file upload in angular

After uploading the image using ng-file-upload to https://angular-file-upload-cors-srv.appspot.com/upload
,I get in response only the image name.
Now, if I want to render the image in html
<img ng-show="createRecipeForm.file.$valid" src="{{response.filename}}" class="img-rounded" height="100">
or
<img ng-show="createRecipeForm.file.$valid" ngf-thumbnail="{{imageArray[$index]}}" class="img-rounded" height="100">
How do I get my image here? I am using this for demo purpose and need to get it from my local computer only for now.
I see can not give path to a drive on computer here for src.
So, how do I render the image in html given that I have the file name.
If you are storing the file using a web server, you should have access to the relative path of the server to use before filename in src="{{response.filename}}"
Check where in the folder structure you are storing them, then you can try: (e.g.)
src="/AppData/{{response.filename}}"

Resources