[英]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.我正在使用 laravel 框架,我必须创建一个配置文件,所以我更改了在 Auth 中创建的表 User .. 一切正常。 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这是我的标志图片我放了 {{URL::asset}} 因为它没有显示在其他页面中
<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设置asset
如下
<img src="{{ asset('img/avatar/'.Auth::user()->picture) }}">
Or if you want to use URL::asset
then或者如果你想使用URL::asset
那么
<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) }}">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.