作者:朗月清风的海角 | 来源:互联网 | 2023-05-26 11:59
在我的Laravel项目中,我正在尝试使用刀片将图像加载到我的视图中,但它显示为断开的链接.我用firebug检查它,src指向图像但没有显示.
我的图片位于我项目的public/images/users/3/profilePictures /
这是我![]()
在view.blade.php中的内容
但是,当我加载页面时,我得到了这个:
![在此输入图像描述](https://img.php1.cn/3cd4a/1eebe/cd5/0a0ce631ec450943.webp)
当我用萤火虫检查图像时,我看到了这个:
![在此输入图像描述](https://img.php1.cn/3cd4a/1eebe/cd5/d34245582687a4e6.webp)
这是正确的src,图像确实存在于我的public/images/users/3/profilePictures /目录中
任何人都知道为什么会这样吗?
1> Mohebifar..:
这可能会导致您处于不代表基本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')
帮助器.
或者只是`asset()`:)