简体   繁体   English

图像未显示在 firebase 托管网站上

[英]Images not showing up on firebase hosted website

i run command firebase deploy in my Project/public folder which contains index.html , main.css and an images folder, my webpage is hosted but images are not showing up in my webpage.我在我的项目/公共文件夹中运行命令firebase deploy ,其中包含index.htmlmain.css图像文件夹,我的网页已托管但图像未显示在我的网页中。

Hope this will help Someone who face this type of issue:希望这会对面临此类问题的人有所帮助:

Problem问题

Images not showing up on firebase hosted website.图像未显示在 firebase 托管网站上。 This problem mainly arise due to some version issues..这个问题主要是由于一些版本问题..

Solution to the Problem:问题的解决方案:

  1. This may cause due to the dot extension format(.png, .jpg..etc) of the image.这可能是由于图像的点扩展格式(.png、.jpg..等)造成的。 Changing this will help to resolve the problem [eg.改变这将有助于解决问题[例如。 If your image format is.png just change it to.jpg format and check].如果您的图像格式是.png,只需将其更改为.jpg 格式并检查]。

  2. Next solution is to change the way you give the path to the image ie下一个解决方案是更改您提供图像路径的方式,即

    background-image: url("src/img/imageName.format"); //normal way background-image: url("../img/ImageName.jpg"); //use this way

=> Reffer site: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/Dealing_with_files#:~:text=Some%20general%20rules%20for%20file%20paths%3A => 参考网站: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/Dealing_with_files#:~:text=Some%20general%20rules%20for%20file%20paths%3A

Thanks in Advance:)提前致谢:)

I faced the same problem. 我遇到了同样的问题。 Resolved it by providing relative path urls 通过提供相对路径网址解决了这个问题

example: Instead of using img src="User/local/..../img/pic.png use img src="img/pic.png" 示例:而不是使用img src="User/local/..../img/pic.png使用img src="img/pic.png"

where img is folder in public directory containing all the images 其中img是包含所有图像的公共目录中的文件夹

Since firebase console is reading your page from public directory,( which you might have created after all the coding done in some other folder)so changing the parent folder will not effect the webpage images if you use relative path of image. 由于firebase控制台正在从公共目录读取您的页面(您可能在其他文件夹中完成所有编码后创建),因此如果您使用图像的相对路径,更改父文件夹将不会影响网页图像。

Now use firebase deploy. 现在使用firebase部署。

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

相关问题 “www.'' 无法在 Firebase 中托管的网站上工作 - "www.'' Not working on website hosted in Firebase Angular:firebase托管的网站登录失败 - Angular: the website hosted on firebase fail to log in Firebase 托管网站显示欢迎页面而不是实际网站 - Firebase hosted website shows welcome page not the actual website Firebase 主机没有显示应用程序? - Firebase hosting not showing up app? 为什么我的图像没有从 firebase 火库中显示? - Why my images is not showing from firebase firestore? 网站访客计数器显示为“[object Object]” - Website visitor counter showing up as "[object Object]" iOS Firebase Crashlytics 未在仪表板中显示崩溃 - iOS Firebase Crashlytics not showing up crashes in Dashboard Firebase 图像检索并不总是出现在 ReactJS - Firebase image retrieval not always showing up in ReactJS 错误 404 页面显示而不是 wordpress 管理面板(网站托管在 AWS EC2 实例、Ubuntu 上) - Error 404 page showing instead of wordpress admin panel ( Website Hosted on AWS EC2 instance, Ubuntu) 下载托管在 Firebase 中的图像 - Download an image hosted in Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM