[英]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.html , main.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:问题的解决方案:
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 格式并检查]。
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.