Home > Enterprise >  How do I get the relative file path of an image or video?
How do I get the relative file path of an image or video?

Time:07-23

Each time I try to add an image to visual studio code I keep having to inspect and get the entire image source code.

I would like to just use /images/down-chevron.png.

Any help? Thanks!

Example of my code:

 <img src="file:///C:/Users/tashe/Downloads/CODING CAGES/Cleant Dental services/images/up-chevron.png" id="upArrow" onclick="upArrow()">
 <img src="file:///C:/Users/tashe/Downloads/CODING CAGES/Cleant Dental services/images/down-chevron.png" id="downArrow" onclick="downArrow(
</div>



CodePudding user response:

You're almost there. Just replace the "file:///C:/Users/tashe/Downloads/CODING CAGES/Cleant Dental services" with a dot from the src attribute and you'll be good to go.

 <img src="./images/down-chevron.png" >

In VS Code, depending on your autocomplete settings, each time you write src, should give you options for autocomplete including the images folder.

CodePudding user response:

You could store the images you'd like to use in a folder called img inside of the folder where your HTML and css live. Then for the img tag in the HTML you could use something like

<img src="./img/down-chevron.png">

The ./ lets you navigate through the working tree. Using ../ would go back two directories if needed.

  • Related