简体   繁体   English

图片标记仅返回首页上的用户头像,而不返回其他页面上的头像

[英]image tag only returning user avatar on homepage not on other pages

  1. I have a nav bar a home page and a page to post a question 我有一个导航栏主页和一个发布问题的页面
  2. user avatar is showing on home page not on post a question page below is my nav bar 用户头像显示在主页上,而不是发布问题页,下面是我的导航栏

     <a style="position:relative; padding-left:50px;"> <img src="uploads/avatars/{{ $currentUser->avatar }}" style="width:32px; height:32px; position:absolute; top:10px; left:10px; border-radius:50%"> Welcome {{ $currentUser->name }} </a> 

Use a absolute path: <img src="/uploads/avatars/... 使用绝对路径: <img src="/uploads/avatars/...

Notice the '/' at the beginning of the path. 注意路径开头的“ /”。

Example: 例:

  • Home page: demo.com/ 主页: demo.com/

  • Any page: demo.com/any-page/ 任何页面: demo.com/any-page/


Case 1: 情况1:

<img src="uploads/avatars/{{ $currentUser->avatar }}"
  • Home page: Url image is demo.com/uploads/avatars/... 主页:网址图片为demo.com/uploads/avatars / ...
  • Any page: Url image is demo.com/any-page/uploads/avatars/... => Url image wrong 任何页面:网址图片为demo.com/any-page/uploads/avatars / ... => 网址图片错误

Case 2: 情况2:

<img src="/uploads/avatars/{{ $currentUser->avatar }}"
  • Home page: Url image is demo.com/uploads/avatars/.... 主页:网址图片为demo.com/uploads/avatars / ....
  • Any page: Url image is demo.com/uploads/avatars/.... => Url image correct 任何页面:网址图片为demo.com/uploads/avatars / .... => 网址图片正确

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Symfony 项目仅适用于主页。 当我导航到其他页面时,Apache 返回 404 - Symfony project works only homepage. When I navigate to the other pages Apache returns 404 在首页的多个页面中显示带有图像的类别-Magento - Display Categories with Image in Multiple Pages of Homepage - Magento 用户头像插件wordpress,如何显示图片 - User Avatar plugin wordpress, how to display image .htaccess配置,将wordpress网站的主页设置到子目录,将其他页面设置到根目录 - .htaccess configuration for homepage of wordpress site to a subdirectory and other pages to root directory Wordpress 迁移后主页未加载,所有其他页面加载 - Homepage not loading after Wordpress Migration, all other pages load Laravel 5.1 可以访问首页但不能访问其他web页面 - Laravel 5.1 can access the homepage but not the other web pages 首页未加载,所有其他页面正在加载 WordPress 迁移 - Homepage not loading, all other pages loading in WordPress migration Wordpress最近发布的帖子未显示在首页上,而是显示在其他页面上 - Wordpress recent posts not showing on homepage, but shows up on other pages 服务器尝试下载主页-其他页面/文件显示正常 - Server tries to download homepage - other pages/files display fine 仅在主页opencart上显示图像类别 - display image categories only on homepage opencart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM