在我的Laravel项目中,我尝试使用刀刃将图像加载到视图中,但它显示为断开的链接。我用萤火虫检查它,并且src指向图像,但是什么也没显示。
我的图片位于项目的public / images / users / 3 / profilePictures /
这是我<img>
的view.blade.php文件
<img class="com-profile-picture" src="images/users/{{ $follower->id }}/profilePictures/50thumb-{{ $follower->profilePicture->url }}" alt="{{ $follower->first_name }} {{ $follower->last_name }} Profile" width="50" height="50">
但是我在加载页面时得到了这个:
当我用萤火虫检查图像时,我看到以下内容:
那是正确的src,并且该图像确实存在于我的public / images / users / 3 / profilePictures /目录中
有人知道为什么会这样吗?
这可能是由于您所使用的路由不代表基本URL。您应该为资产生成相对于public/
文件夹的URL 。使用URL::asset('path/to/asset')
生成的URL。
{{ URL::asset("images/users/{$follower->id}/profilePictures/50thumb-{$follower->profilePicture->url}") }}
或者如@lukasgeiter所述,您可以简单地使用asset('path/to/asset')
helper。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句