Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Maha Mamoor
1,414 PointsUploading Images- How to build your own website
I uploaded my personal images to workspace. When I view my website a question mark in a box comes up. The pictures do not show. Does this have something to do with the size of my pictures? How can I make the pictures visible?
9 Answers
Kevin Lozandier
Courses Plus Student 53,747 PointsHi, Maha:
It has to do more with the path you've defined in the src attribute of your image tags. A question mark was shown because the path you've provided could not be used by the browser to find the correct image you were hoping to see based on where the html file is:
<img src="myimage.png" alt="This is me smiling in San Jose" />
This image will be shown only if the image and the html are in the same place without any folders or other containers between them:
- myfolder
-- index.html
-- myimage.html
This is rarely the case, usually you do the following:
<img src="./images/myimage.png" alt="This is me smiling in San Jose" />
This explicitly states relative to where the html file is in, find the image inside a folder called images:
- myfolder
-- index.html
- images
-- myimage.png
You have to make sure you have your relative or absolute paths defined correctly to see the images you're hoping to show the whole world eventually. :)
idan ben yair
10,288 PointsOk thanks for posting your code as me and Kevin were stating. The path is really important, I myself had this happen I used to spend sleepless nights wondering why things dont appear lol.
is the image located in the img folder? is it a jpg, png or something else? make sure you got the name of the file exactly how it suppose to appear and make sure you are directing it to the exact folder.
Let me know if that works for you :)
Maha Mamoor
1,414 PointsThe pictures are located in the img folder and they are jpg.
Am i directing the pictures to the image folder correctly?
idan ben yair
10,288 Pointsalright so it should look like this:
<img src="./img/photo 4.jpg" alt="">
Maha Mamoor
1,414 PointsIt still isn't working, but I'll definitely play around with it. Thanks for all your help Idan! :)
Jason Anello
Courses Plus Student 94,610 PointsHi Maha,
Based on your code you should have your images in a sub-folder called "img".
You have spaces in your file names. You might be ok with url encoding the space with %20 so img/photo 4.jpg becomes img/photo%204.jpg
However, I would recommend not using spaces in your filenames. You can use an underscore, _ anywhere you'd like to use a space.
img/photo_4.jpg
I would add the underscores to your files and in the paths in your html code. For both the link and the image.
I noticed too that you have .jpeg in the link and .jpg in the image src. You should see which one your image file is and switch one to match the other.
idan ben yair
10,288 PointsHello Maha, it might have something to do with your code, can you copy the code you are trying to use? It will help me understand the problem better.
You need to make sure you are using the correct path when using an image in HTML or CSS
Thanks :)
Maha Mamoor
1,414 Points <ul id="gallery">
<li>
<a href="img/photo 1.jpeg">
<img src="img/photo 1.jpg" alt="">
<p>Insert description.</p>
</a>
</li>
<li>
<a href="img/photo 2.jpeg">
<img src="img/photo 2.jpg" alt="">
<p>Insert description.</p>
</a>
</li>
<li>
<a href="img/photo 3.jpeg">
<img src="img/photo 3.jpg" alt="">
<p>Insert description.</p>
</a>
</li>
<li>
<a href="img/photo 4.jpeg">
<img src="img/photo 4.jpg" alt="">
<p>Insert description.</p>
</a>
</li>
</ul>
</section>```
idan ben yair
10,288 Pointswhen typing myimage.png Kevin was referring to your image, it could be any name, you can decide which name it would be. the folder would be images in Kevins example.
allyspruill
383 PointsOK so I'm having the same problem and I'm doing what you guys are telling Maha to do. Still nothing, no pictures. Here is my code:
<ul>
<li>
<a href=" ./img/Alice-In-Wonderland-Tim-Burton.jpg"></a>
<img src=" ./img/Alice-In-Wonderland-Tim-Burton.jpg" alt="">
<p>pic description</p>
</a>
</li>
<li>
<a href=" ./img/alice2sm.jpg"></a>
<img src=" ./img/alice2sm.jpg" alt="">
<p>pic description</p>
</a>
</li>
<li> <a href=" ./img/images.jpg"></a> <img src=" ./img/images.jpg" alt=""> <p>pic description</p> </a>
<a href=" ./img/Tim-Burton-s-Alice-In-Wonderland-alice-in-wonderland-2010-13677630-1360-768.jpg"></a>
<img src=" ./img/Tim-Burton-s-Alice-In-Wonderland-alice-in-wonderland-2010-13677630-1360-768.jpg" alt="">
<p>pic description</p>
</a>
</li>
</ul>
Thanks!
Jason Anello
Courses Plus Student 94,610 PointsI would verify that you have these images in an "img" sub-folder where your index page is and that you're matching both the upper and lowercase letters in both the path and the filename itself.
It would be a good idea to consistently use lowercase to prevent any case mismatching problems.
idan ben yair
10,288 PointsHi Allyspruill, are you sure the file extension that you are using is correct? is it .jpg? double check that let me know if that works.
allyspruill
383 PointsHey, They are png I typed the code in wrong up there.
Maha Mamoor
1,414 PointsMaha Mamoor
1,414 PointsJust to clarify, you are saying:
Make my own folder called myimage.png and drag my pictures in there then change the code to read myimage.png and not image.png?
Also, how long did it take you to get to your score of 28,000? :O
Kevin Lozandier
Courses Plus Student 53,747 PointsKevin Lozandier
Courses Plus Student 53,747 PointsTo clarify,
srcis looking for a filename ending with an file extension . For example the image file I used for my example was myimage.png: The name of the file ismyimageand the file extension ispng—a file that has the name ofmyimagewith a file extension ofpng.Depending on what browser you're using, the file extension, and the element being used, you see a particular result that''s not merely selectable text—an image, a video, and so on.
The things before the file name is the path to get to the resource. This may be how to access the resource relative to the page via a folder called images (
./images/) or an absolute address that points to a picture of Rihanna (http://music-news.redigi.com/wp-content/uploads/2012/10/Rihanna-4-1170x731.jpg).In general, you specify where to find the image using particular syntax if necessary about its whereabouts.
Tips on choosing a good file name
As Maha pointed out, it's not a good idea to name your file using certain white space and other characters that are reserved for other purposes.
Regarding points
A long time, but points don't matter; it's what you do with that knowledge.
Regina Dailey
1,199 PointsRegina Dailey
1,199 PointsI fixed the problem. It finally occured to me to check whether the uploaded file was .jpg or .png. It was .jpg. So I switched it to .png and made sure everything else was .png, saved and when I het preivew voila I had my picture.