When I use the 'Live Server' Extension in VS Code my website looks great.
I deployed on vercel and the only thing showing are my social media buttons and the footer. Everything in between are 'alt=""' broken images. (alt="" being an example of course.)
An example of one of the lines:
<div class="container" id="roadmap">
<img class="center" src="/public/images/Roadmap Button.png"
alt="roadmap" style="width: 50%;height: 100%; margin-left:
25%;">
<img class="w-100" src="/public/images/Roadmap.png"
alt="roadmap">
</div>
My index.html, styles.css, and images folder is all in the public folder. Once again, on local server everything looks great, but when I deploy it, everything works great except for the images. They just won't show. Only the alt tag will (alt="").
I also cleared my cache, and looked on different browsers and devices. Same thing. Any help on this would be greatly appreciated. I am somewhat a beginner at this still. So I am going for more of a static/navigational website.
would appreciate some help here, my img html tag has the correct file path. However, when I launch the express server and try to view the image on vscod Browser Preview, I cannot see it (example picture in the link below). What could be the problem?
<div class="dashboard"><!--Dashboard START-->
<section class="navigation"><!--Navigation START-->
<img src="imgs/iHome.png" alt="">
</section><!--Navigation END-->
This is a picture of the html file along with the directories on the left and the html img tag in the middle, and the Browser Preview with the missing image on the right
The App needs a src folder that has a sub folder assets. your Frontend js should be hosted in the src folder.
put your image in the src -> assets -> images/pic01.jpeg
then call it like this:
<img src="assets/images/pic01.png" alt="">
I should note that the website I'm working on is meant to be pretty simple.
The way I have my website files organized is that under one folder containing the entire website, I have the .html file for the home page, which contains links to different pages inside it for photos, videos, etc. Each of these pages have their own folders.
Attached here is the code I have for one of these pages, meant for my photos. I learned from this thread (Link not going back to home page) that if you just have:
Home
That the link will take you back to the index/root directory.
(Is this different from the home page? Sorry, I'm a noob.)
Although, when I originally had it has just the code above, the link takes me to this weird gray page that just shows all of the files of my website (is that root place or whatever it's called?).
Although, I see that I'm able to from there just simply add the .html file for my home page in that link directory, so the code I have now seems to work.
Is this an okay way to have a link to go back to the home page? Thank you for your time.
<!DOCTYPE html>
<html>
<style>
div.img {
display: inline;
max-width: 650px;
}
</style>
<body>
<div> <!--Home Button-->
<a href="/homepage.html" style="float: right; margin-right: 100px;">
Home
</a>
</div>
<div class="img">
<img src="1.jpg" width="384px;" height="384px;">
<img src="2.png" width="384px;" height="384px;">
<img src="3.png" width="384px;" height="384px;">
<img src="4.JPG" width="384px;" height="384px;">
<img src="5.png" width="384px;" height="384px;">
</div>
</body>
</html>
If it works and you are okay with having the path /homepage.html as your home page, then it is a perfectly good and logical way of linking back to the home page.
As Kei mentioned in the comment, it is highly advisable to rename this file to index.html as most web servers and browsers will default to this file name as the root. For a lot of people, it's more desirable to just go to a domain (ie: mydomain.com) as the home page, rather than having to type in mydomain.com/homepage.html.
All this to say, if you rename your home page file to index.html and serve this website through a web server of some sort (Apache for example), then you can simply use / as a path and it will bring you directly to the home page. I know that you mentioned that you are a beginner, so this may be slightly outside of the scope of what you are asking, but just letting you know for the future. Good luck!
Can someone give me feedback on this: Made the code using a third party image host (i've used them before). When I put the code in where I want it on the page (after checking on google inspect) it doesn't show up at all.
<div id="header"> <img src="preview.ibb.co/n25Rcy/banner_18.jpg"; width="920" height="174">
You need to add the protocol at the start of the url (I used https in the code below).
<div id="header"> <img src="https://preview.ibb.co/n25Rcy/banner_18.jpg"; width="920" height="174">
<body style="background-color: paleturquoise">
<h2 style="color: red">Duke's soccer League: Home Page<br/></h2>
<ul style="list-style-type: circle">
<li style="font-size: larger">All Leagues list</li>
<li style="font-size: larger">Register for a League (TBA)<br/><br/></li>
</ul>
<h2 style="color: red">League Administrator</h2>
<ul style="list-style-type: square">
<li style="font-size: larger">Add a new League (TBA)</li>
<img src="C:\Users\VIRK\Desktop\66.jpg" width="400" height="400" ></img>
</ul>
</body>
I am currently practice with JSP and I try this html code to make a web page on NetBeans IDE 7.0 but when I'm build and run the page no error in code but the image is not showing in the browser.
Edited:
Here I have given the screenshot of the NetBeans IDE where you can see the image is existing in Web-INF folder and the index.jsp page too and I tried with "/" before the image name but it won't work. The exact path of my project is C:\Users\VIRK\Documents\NetBeansProjects\practiceJSP .
<img src="/66.jpg" width="400" height="400" ></img>
I find out the way how to set the image path just remove the "/" before the destination folder as "images/66.jpg" not "/images/66.jpg" And its working fine for me.
You put inside img tag physical path you your image. Instead of that you should put virtual path (according to root of web application) to your image. This value depends on location of your image and your html page.
for example if you have:
/yourDir
-page.html
-66.jpg
in your page.html it should be something like that:
<img src="66.jpg" width="400" height="400" ></img>
second scenario:
/images
-66.jpg
/html
page.html
So your img should look like:
<img src="../images/66.jpg" width="400" height="400" ></img>
Your path should be like this : "http://websitedomain//folderpath/66.jpg">
<img src="http://websitedomain/folderpath/66.jpg" width="400" height="400" ></img>
I don't know where you're running the site from on your computer, but you have an absolute file path to your C drive: C:\Users\VIRK\Desktop\66.jpg
Try this instead:
<img src="[PATH_RELATIVE_TO_ROOT]/66.jpg" width="400" height="400" />
UPDATE:
I don't know what your $PROJECTHOME is set to. But say for example your site files are located at C:\Users\VIRK\MyWebsite. And let's say your images are in an 'images' folder within your main site, like so: C:\Users\VIRK\MyWebsite\images.
Then in your HTML you can simply reference the image within the images folder relative to the site, like so:
<img src="images/66.jpg" width="400" height="400" />
Or, assuming you're hosting at the root of localhost and not within another virtual directory, you can do this (note the slash in the beginning):
<img src="/images/66.jpg" width="400" height="400" />
all you need to do is right click on the jsp page in the browser, which might look like "localhost:8080/images.jpg, copy this and paste it where the image is getting generated
I had same kind of problem in Netbeans.
I updated the image location in the project and when I executed the jsp file, the image was not loaded in the page.
Then I clean and Built the project in Netbeans. Then it worked fine.
Though you need to check the image actually exists or not using the image URL in the browser.
I had a problem where the images would not show and it wasn't the relative path. I even hard coded the actual path and the image still did not show. I had changed my webserver to run on port 8080 and neither
<img src="c:/public/images/<?php echo $image->filename; ?>" width="100" />
<img src="c:/public/images/mypic.jpg" width="100" />
would not work.
<img src="../../images/<?php echo $photo->filename; ?>" width="100" />
Did not work either. This did work :
<img src="http://localhost:8080/public/images/<?php echo $image->filename; ?>" width="100" />
do not place *jsp or *html in root folder of webapp and images you want to display in same root folder browser cannot acess the image in WEB-INF folder
I also had a similar problem and tried all of the above but nothing worked.
And then I noticed that the image was loading fine for one file and not for another. The reason was: My image was named image.jpg and a page named about.html could not load it while login.html could. This was because image.jpg was below about and above login. So I guess login.html could refer to the image and about.html couldn't find it.
I renamed about.html to zabout.html and re-renamed it back. Worked.
Same may be the case for images enclosed in folders.
the easy way to do it to place the image in Web Content and then right click on it and then open it by your eclipse or net beans web Browser it will show the page where you can see the URL which is the exact path then copy the URL and place it on src=" paste URL " ;
If we are using asp.net "FileUpload" control and want to preview image before upload we can use below code.
<asp:FileUpload ID="fileUpload" runat="server" Style="border: none;" onchange="showpreview(this);" />
<img id="previewImage" src="C:\fakepath\natureImage.jpg">
<script>
function showpreview(Imagepath) {
var reader = new FileReader();
reader.onload = function (e) {
$("#previewImage").attr("src", e.target.result);
}
reader.readAsDataURL(Imagepath.files[0]);
}
</script>
Another random reason for why your images might not show up is because of something called base href="http://..." this can make it so that the images file doesn't work the way it should. Delete that line and you should be good.
You need to import your image from the image folder.
import name_of_image from '../imageFolder/name_of_image.jpg';
<img src={name_of_image} alt=''>
Please refer here.
https://create-react-app.dev/docs/adding-images-fonts-and-files -
The folder names in the path should not contain the space
write fullstack /asset/image.jpg instead of full stack/asset/image.jpg