Github无法加载或不显示图片,只需要修改host文件即可:
文件路径
- Mac:/etc/hosts
- Win:c:\windows\system32\drivers\etc/hosts
以Mac为例:
- 1.Mac终端输入
sudo vi /etc/hosts
- 2.输入密码后,点击
i
键,进入Insert模式,将下面内容拷贝进去
# GitHub Start
192.30.253.112 Build software better, together
192.30.253.119 gist.github.com
199.232.96.133 avatars.githubusercontent.com
199.232.96.133 user-images.githubusercontent.com
151.101.184.133 assets-cdn.github.com
151.101.184.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
151.101.184.133 avatars0.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com
# GitHub End
- 3.点击
esc
键,然后输入:wq
保存退出即可。 - 4.再去打开或刷新Github页面,图片已经可以加载出来了。
注意:
- 不熟悉终端操作步骤的可以将hosts文件拷贝到桌面,修改编辑好内容后再替换原来的hosts文件,替换是需要输入电脑密码;
- 如果仍然不显示图片,则按照下面方法:
- 右键图片,复制图片链接,去此网站解析ip地址: https://www.ipaddress.com/
- 例如:图片链接为:https://camo.githubusercontent.com/xxxxxxxxxxxxxxxxxx
- 解析到的ip地址是:185.199.108.133
- 然后使用最新的ip地址:185.199.108.133,替换上述旧的ip地址:151.101.184.133