is their any other way
food_img = new Image();
food_img.src = “Assets/apple.png”;
other than this ?
How to add the image src
Hey @ARYAN27
Hope you’re enjoying the course.
I am not sure I understood your question exactly. What do you mean by any other way. Any other way to set image src. Or use another image. Please let me know.
here we are adding a source of file where our image is stored
my question is ?
1.)is we have to copy whole path of assests where our image folder is ?
or just assest/image.png?
2.)can we do it by another way by making a url of image ?
- assest/image.png is actually the entire image path from root folder
- What you’re using is actually the URL of the image from root folder
If your doubt is resolved please mark it as closed.
okay for example like i used background wallpaper like this:-
#mycanvas{
background-image: url(“https://user-images.githubusercontent.com/42711978/79313148-862b8680-7f1d-11ea-9128-a3d13fb245c7.jpg”);
border: 20px solid green;
}
@ARYAN27
So that is again a URL but here the source is external
So yeah you can use this way as well
But with external images you might not be able to load image timely
If image size if small and resource is always required its better to keep it under assets
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.