解决GitHub不显示图片问题

刚开始使用github时很多时候会碰到图片不显示的问题以下为解决方法

不显示图片原因:一般是因为DNS无法解析到图片外链地址的ip地址

解决方法:很简单,我们可以通过外国的ip地址测试找到该域名具体对应的ip地址,之后手动地加到我们本机的host文件中(相当于DNS映射)

具体步骤

第一步:检查域名

我们可以右键点中不能显示的图片,点击检查,点击控制台,可以看到failed to load 字样,后面就是没有显示出来的图片地址:

我这里是https://raw.githubusercontent.com/WZMIAOMIAO/deep-learning-for-image-processing/master/pytorch_segmentation/fcn/torch_fcn.png

我们要查找的域名是http://到.com之间:在这里为:raw.githubusercontent.com

第二步:查找域名对应的IP

访问 https://www.ipaddress.com/ ,在页面输入刚刚找到的域名:raw.githubusercontent.com

可以得到IP地址如下:

第三步:修改hosts文件

找到本机hosts文件,一般路径地址为:C:\Windows\System32\drivers\etc\hosts

打开hosts修改,将上面对应的IP和域名放到hosts文件末尾

即添加:

185.199.108.133   raw.githubusercontent.com
185.199.109.133   raw.githubusercontent.com
185.199.110.133   raw.githubusercontent.com
185.199.111.133   raw.githubusercontent.com
2606:50c0:8000::154 raw.githubusercontent.com
2606:50c0:8001::154 raw.githubusercontent.com
2606:50c0:8002::154 raw.githubusercontent.com
2606:50c0:8003::154 raw.githubusercontent.com

ps: 添加完此映射关系之后,可以使用这个命令刷新下本地的DNS缓存:ipconfig/flush,打开CMD,输入 ipconfig/flushdns 即可。

以下是重新显示出来的图片:

下面是比较全的dns配置,可以直接加到末尾

140.82.113.3      github.com
140.82.114.20     gist.github.com
 
151.101.184.133    assets-cdn.github.com
151.101.184.133    raw.githubusercontent.com
199.232.28.133     raw.githubusercontent.com 
151.101.184.133    gist.githubusercontent.com
151.101.184.133    cloud.githubusercontent.com
151.101.184.133    camo.githubusercontent.com
199.232.96.133     avatars.githubusercontent.com

  • 22
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
如果在GitHub页面上无法显示图片,有几种可能的原因。一种可能是图片的路径不正确。你可以检查README文件中图片的地址是否正确,确保图片的路径与实际存储位置匹配。另一种可能是图片的权限设置不正确,你需要确保图片的权限设置为公开,这样其他人才能够在GitHub上访问到图片。还有一种可能是图片的大小超过了GitHub的限制,GitHub有一个文件大小限制,如果图片大小超过了这个限制,就无法显示。另外,如果你使用了本地图片链接而不是网络图片链接,图片是无法在GitHub显示的。你可以将图片上传到一个图床或者图片托管服务,然后使用图片的网络链接来在GitHub显示图片。这样其他人就可以访问到图片了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [解决提交README.md到github后,图片无法显示问题](https://download.csdn.net/download/weixin_38732740/14036934)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [解决github 图片无法显示问题](https://blog.csdn.net/weixin_45549370/article/details/119383624)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [解决github上的图片无法显示问题](https://blog.csdn.net/CSDN_Gao_16/article/details/126203665)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值