2
votes

I am using Laravel, and I want to display an image. I have the public/img folder, and this is the code

<img src="{{ URL::asset("img/background1.jpg") }}" alt="Unsplashed background img 1">

The image does not appear. When I inspect the page however, it returns the correct link, http://localhost:8000/img/background1.jpg but it says 0x0 px.

2
Could you post the html that's returned?Mei Gwilym
'<img src="localhost:8000/img/background1.jpg" alt="Unsplashed background img 1">'Vedran Korponajić
What happens when you open http://localhost:8000/img/background1.jpg directly in your browser?John Bupit
It opens the image.Vedran Korponajić
Looks like the semi colon in the img element might be breaking things.Mei Gwilym

2 Answers

1
votes

Add a / in front as the public folder is the root...

<img src="{{ URL::asset("/img/background1.jpg") }}" alt="Unsplashed background img 1">
0
votes

Are you getting correct image when you open this link in browser? If so, then it would be issue with img height-width. Try setting static height-width for img and check.

Hope this helps..