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) }}">
Related
I am new in using Livewire for my cart in my e-commerce Laravel 7 project. I want to show the product image of each item in the cart. I have #foreach ($cartItems as $item) on my table data. When I try this code
<img src="{{asset('storage/'.$item->cover_img)}}">
to try to show the images saved to my storage path, I get an error like the image above. But when I try:
<img src="{{asset('storage/'.$item['cover_img'])}}">
I'm getting an ErrorException Undefined index: cover_img. All the other $item is working and getting the needed data except the image. On my other blades without livewire <img src="{{asset('storage/'.$item->cover_img)}}> works fine.
How do I do this properly in livewire? Any advice would be appreciated. Thanks in advance!
When I do a {{dd($item)}}, this is what I get:
This solved my problem:
<img src="{{ asset('storage/'.$item['associatedModel']['cover_img']) }} " />
Thanks!
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">
This is for a small school assignment.
We are trying to create and deploy a search website of local cricket players.
I have everything running locally the only thing is I need to use is asset on my images to get them to deploy properly.
currently I have in my local
<img src="/images/{{$player['image']}}" class="playerimg">
I have tried concatenating it but to no avail.
The reason I have a variable $player is because we are pulling data from two tables and looping around the array.
Any help would be greatly appreciated
Edit: Solved Thank you all for your help ! code below
<img src="{{ asset('images/'.$player['image']) }}" class="playerimg">
Laravel - Helpers: asset()
https://laravel.com/docs/master/helpers#method-asset
<img src="{{ asset('images/'.$player['image']) }}" class="playerimg">
There are several ways to display the image.
I'm assuming index.php in public folder.
asset() Generates a URL to an application asset (code)
Use for files that are directly served such as CSS, images, javascript.
Only accepts a direct path.
{{ asset('images/'.$player['image']) }}
// http://www.example.com/public/images/abc.png
If you stored your image in storage folder then,
<img src="{{ storage_path('images/'.$player['image']) }}">
Make sure config.php should be configured properly for storage_path.
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') }}">
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"/>