Image source is wrong Spring - html

I am trying to show an image which is located in a folder in my Desktop. My problem is this when i set source to image thymeleaf or spring engine appends localhost:8080 to its path.
<img alt="" src="/Users/abdullahtellioglu/Desktop/ZambakResimler/yarnartjeans.jpg">
This is the image path. I also tried this one.
<img th:src="#{/Users/abdullahtellioglu/Desktop/ZambakResimler/yarnartjeans.jpg}" alt="" />
Both of them gives me the following path.
http://localhost:8080/Users/abdullahtellioglu/Desktop/ZambakResimler/yarnartjeans.jpg
I am not sure how to remove localhost:8080 from path and make the path absolute.

What are you doing is not how a server should works. When you want to make available some resource from your webapp you need to it to your web app resources. Here is a brief example of how could you fix it.
Go to the folder src/main/resources and create a folder called static.
Under that folder create another one called img and inside copy your image. So we would have something like this now:
src
main
resources
static
img
yarnartjeans.jpg.jpg
Now go to your thymeleaf HTML page and use this
<a href="product_detail.html">
<img th:src="#{/img/yarnartjeans.jpg}" alt=""/>
</a>
Now your HTML page will load your image correctly
Good luck

Related

HTML image not showing why

code:
Why am I not able to see any image here to open amazon?
NOTE: image is saved as th.jfif on my desktop and not in any folder
was expecting to see the image
The issue you are having is very likely due to your image not being in the correct location from where your img is expecting it to be.
I would say take the image from your desktop and place it in a folder, maybe called site. Then put your HTML file and image file in the same site folder and load your page again. Then your path mapping should be accurate and your image will render.
I say it is your path mapping because rendering your HTML link using an online image works just fine.
<img src="https://turnerduckworth.com/sites/default/files/styles/case_study_single_image_s_2x/public/2019-03/5_Amazon_Lettermark_2560.jpg?h=a92f03cd&itok=2nBmNv14" alt="website" width="100">
Surely this is to do with having no file or folder structure. Your image and web page must be detailed relatively to each other.
<img src=" path to the image from the web page location ">
If your web page has a folder with it called images and inside it are all your.... images.
The path will be
src="images/picture-title.jpg"
Read about file structure. To begin with, put your web page inside a folder of it's own and also in that folder create an images folder.
I suspect the path does not match the location of the image you saved. the whole tutorial is on here .
for the example, you saved your image in path images , so you should should type it like this:
<img src="/images/th.jfif.jpeg">
and don't forget to write down the image file extension clearly. hope its help

How can I host SVG images on my website using firebase?

I have deployed a site to Firebase hosting and everything works great, expect that the images are not loading.
I'm linking to them in the public folder that I deploy to the host.
Do I need to add them to something like FireStore and link to that URL?
<img class="img-fluid img" src="/Users/myprofile/desktop/folder/public/name.svg" alt="">
(I have removed the original path)
The alt is empty.
Thank you
The problem was that I was linking with the full url.
Like so:
src="/Users/myprofile/desktop/folder/public/name.svg"
As the pictures was in the same public folder, I only need to use the name.svg.

Adding img src from Mapping Drive

I'm trying to make website with localhost. The problem is, I can't get the image from mapping drive.the location of the image
I'm using <img src='z://--'> and still not working.
The reason why I'm not placing the image on htdocs it's because my pc memory can't handle all the image from that Z file.
Edit :
I'm temporarily using 'image' folder on my localhost, and I'm using the directory like this..
snapshot of my code
What i want it making new src directory from data Z and not images from the localhost...
Thank you for all you're help before.
It seems that the image your trying to show is from a shared folder. You can do the following:
<img alt="" src="file:///SERVER:/FOLDER/IMAGES/sampleimage1.png" />

Some images of folder do not get displayed on web page

On my webpage www.example.com I display images next to texts. Some pictures of the folder "minipics" are not getting displayed.
Path in HTML:
<img src="minipics/m_5b56aa7040b4f1224ee19c17b6f73ab1.jpg" alt="">
However: Opening the image directly in the browser via "www.example.com/minipics/m_5b56aa7040b4f1224ee19c17b6f73ab1.jpg" works!
What is strange: When I after having opened the picture directly via the absolute path (as described above) reload the page on which I expect the images to show up, the picture that I just opened directly gets displayed. But only this picture, NOT the other ones.
Only some pictures that are contained in the folder "minipics" do not get displayed. For example, those pictures uploaded via a new picture upload do get displayed.
Can anybody see a solution to this problem?
you can try to add a slash ( / ) to the file path.
In your url the folder is in the document root. If your file isn't, this can help.
<img src="/minipics/m_5b56aa7040b4f1224ee19c17b6f73ab1.jpg" alt="">
If your folder structure is like below
index.html
minipics
m_5b56aa7040b4f1224ee19c17b6f73ab1.jpg
Then change the code to below
<img src="./minipics/m_5b56aa7040b4f1224ee19c17b6f73ab1.jpg" alt="">
./ means current folder.
Hope this will help you.

Image path doesnot working in YII framework?

Here I have one sub domain and folder in following URL buyjapon.This is website is belong Yii framework.
basically,we called image path as <img src="/images/usd_C.jpg" /> .I create folder in my domain in migrate into that folder, then i want to call image src just like that <img src="/images/usd_C.jpg" /> but it will not show image properly.
I have include base href in head tag
<head>
<base href="http://demo.osiztechnologies.com/buyjapon">
</head>
Note: When i call image src like this <img src="buyjapon/images/usd_C.jpg" /> it will shown correctly. but i want to change entire website by adding buyjapon in image src.
How to call this..Please guide me..
If your URL's to pages do not require the /buyjapon folder name to be present, then one option would be to create an image controller, that opens up the requested image from the images folder, and outputs it to the data stream. I do this in situations where different translations of the same image are required for different users.
However, it looks like maybe your webserver is not set up correctly - if you are using apache have you set up a virtual host for your website? That will probably solve all your issues. Look here: http://httpd.apache.org/docs/2.2/vhosts/examples.html and at your current virtualhost setup to see what to do.