Reputation: 202
I have image name in the database and image upload in public/image
folder.
Now I want to show the image on the web page.
How do I do this?
I am using
<img src="{{ URL::to('/') }}/images/{{ $item->Photo }}" alt="{{ $item->Title }}"/>
Upvotes: 2
Views: 5121
Reputation: 131
{{HTML::image("images/$item->YourDBFieldNameOfImageURL", "ALT description", "");}}
Upvotes: 0
Reputation: 562
You can use the asset() helper function, like so:
<img src="{{ asset("images/$item->Photo") }}" alt="{{ $item->Title }}" >
Upvotes: 2
Reputation: 1857
Easiest way would be to add a method to your user model.
That method will return the url of your image, you will name that method getImageUrl() for example.
your function :
public function getImageUrl(){
return asset($this->image);
}
That way you just have to do something like this in your view
<img src="{{ $user->getImageUrl() }}" />
Then if at some point you change the storage location of your pictures you just have to change it in the getImageUrl function.
Upvotes: 0