show img with url in laravel 5.4 - image

I have a image that want show in slide show I use html tag <img src="">,
I'm new in laravel and I don't Know How to show image in my blade.
How I can use <img> tag in laravel?

<img src="{{ asset('/public/upload/image.jpg') }}">
If your image in public folder

If you have stored images inside laravel public directory then, you can use asset which refers to public/ directory.
If you have image at public/images/abc.png then, you can add image in view like this:
<img src="{{ asset('images/abc.png') }}">

Related

Display image in laravel 7

I store an image with
$cat->picture = $request->file('catpicture')->store('public/catpictures');
$cat->save();
I do a ls in "/var/www/html/project/storage/app/public/catpictures", the image is saved
I created the symlink
php artisan storage:link
The [/var/www/html/project/public/storage] link has been connected to [/var/www/html/project/storage/app/public].
The links have been created.
In my blade I have:
<img src="{{url($cat->picture)}}" class="img-thumbnail" alt="Responsive image">
which is "public/catpictures/IgTx81OYKVymthuzTydFVepGvFZGALeeW1FmHpas.png"
The image doesnt show,what am I missing?
The src is http://127.0.0.1:8000/public/catpictures/IgTx81OYKVymthuzTydFVepGvFZGALeeW1FmHpas.png
Instead of using url, better to use asset to retrieve asset
Actually you don't need to add public prefix in your store() function. When you call store(), it will use the path from config/filesystems.php. The path will be taken from the default disks.
Asset vs Url
<img src="{{asset('/storage/' . $cat->picture)}}" class="img-thumbnail" alt="Responsive image">

Avatar Not Showing Laravel

I'm working with laravel framework, I have to create a profile so I changed the table User created in the Auth.. all works perfectly. I also added a Picture for the Profile picture or Avatar in the User table.
I made a profile page Image are showing and even to my nav bar.
this is the code I used.. and it work in other pages.
<img src="img/avatar/{{Auth::user()->picture}}">
this one is for my logo image I put the {{URL::asset}} because it's not showing also in another pages
<img src="{{ URL::asset('img/weblogo.png') }}">
then it works perfectly in all pages
but when I try to use it in the image from my database, It won't work and said
<img src="{{ URL::asset('img/avatar/{{Auth::user()->picture}}') }}">
syntax error, unexpected '}', expecting ')'
in my view
but when I try this, it won't work with all the pages
<img src="img/avatar/{{Auth::user()->picture}}">
Set asset as below
<img src="{{ asset('img/avatar/'.Auth::user()->picture) }}">
Or if you want to use URL::asset then
<img src="{{ URL::asset('img/avatar/'.Auth::user()->picture) }}">
You don't need to use {{ again inside {{ }}
Change
<img src="{{ URL::asset('img/avatar/{{Auth::user()->picture}}') }}">
to
<img src="{{ URL::asset('img/avatar/'.Auth::user()->picture) }}">

How to us html <img src> to display an image in laravel?

I am trying to src an image into my html. Using Laravel as a backend.
<img class="card-img-top" src="storage/app/public/photos/{{$photo}}" alt="Card image cap">
I have also used the system link command and tried,
<img class="card-img-top" src="storage/{{$photo}}" alt="Card image cap">
In the past this would have been sufficent however, when using Laravel this does not link the image.
Does Laravel not allow direct 'src' links, or am I messing up the 'src' file structure?
Laravel uses blade syntax, variables ($) need to be between {{ }} in order to output their value.
So give <img class="card-img-top" src="storage/app/public/photos/{{ $photo }}" alt="Card image cap"> a try :)
i think the simple call like
<img src="storage/image/{{$data->photo}}" alt="">
$data = result from foreach
photo = column in db.
Correct file path is:
src="storage/photos/{{photo}}"
It skips /app/public
src="{{ url('assets/img') }}/{{ $item->photo }}"
Works for me!

Laravel show s3 image in blade template

I have an image stored in an S3 bucket that is linked to my Laravel app. How can I display this image in a blade template?
So far I have...
<img src= "{{Image::make(Storage::disk('s3')->get('image/' . $filename))}}">
But this is not returning anything.
Does anybody have an example I can see?
The S3 driver has a url function that'll get you a temporary, signed URL to the S3 object, so all you'll need to do is:
<img src="{{ Storage::disk('s3')->url($filename) }}">

How to show image form another folder in laravel 5.2

I want to show picture form another folder. But why it's not working?
<img src="/picture/Capture.JPG" style="width:600px;height:400px">
My folder name is picture and image name is Capture.JPG
To print images ,css and js files correct path laravel have a default function asset()
Try this
<img src="{{ asset('picture/Capture.jpg') }}" style="height:400px;width:400px" >
I find my solution last night.
At first i create a folder in public folder name images. Then i store the picture. And the code formet is here.
<img src="{{url('/images/6.JPG')}}" alt="Image"/>

Resources