Reputation: 5
In my laravel project image is not showing. I am using voyager admin panel.
In database image name
is
banners\March2019\xqem6GRUtqSU6pyWZRDJ.jpg
In blade template using the below code to show image
<img class="d-block w-100" src="{{ url('/images/'.$data->banner_image) }}" data-color="lightblue" alt="First Image">
Through inspect element I got image source as below
http://localhost:8000/images/bannersMarch2019xqem6GRUtqSU6pyWZRDJ.jpg
Here no slash
in this path bannersMarch2019xqem6GRUtqSU6pyWZRDJ.jpg
. But actual path is banners/March2019/xqem6GRUtqSU6pyWZRDJ.jpg
.
Because of this path problem image is not shown. So my question is why there is no slash ? How can I solve that ?
Someone help me please. Thanks in advance.
Upvotes: 0
Views: 1534
Reputation: 95
Please try this below. It should work.
<img class="d-block w-100" src="{{ url('/images/'. '/' . $data->banner_image) }}" data-color="lightblue" alt="First Image">
Upvotes: 0
Reputation: 3065
I believe this is a bug in voyeger. Backslashes in media asset path when saving to db. You can solve it using,
$output = str_replace('\\', '/', $data->banner_image);
You can see this thread for more details : https://github.com/the-control-group/voyager/issues/2834#ref-commit-0d6bffb
Upvotes: 1
Reputation:
Double check your config/filesystems.php storage variable, you must upload / place your images in the
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
The "root" index here determines where your files would be located once you display it in the view, by default, it's being located at storage/app/public
Upvotes: 0