所以社区,
我在 GitHub 存储库自述文件中使用嵌入图像(图标、屏幕截图等),今天注意到我的所有图像在不久前(大约一周左右)工作时都已损坏。一些开发人员朋友的存储库显示出相同的症状和浏览器控制台错误:
Refused to load the image 'https://raw.githubusercontent.com.x.912eb622002e804d2d0bc98027f64e5bb4af.9270fa5c.id.opendns.co
m/s/raw.githubusercontent.com/terrencemm2/terrencemm2/main/assets/japanese_flag.png?X-OpenDNS-
Session=_912eb622002e804d2d0bc98027f64e5bb4af9270fa5c_MHRsNPzb_' because it violates the
following Content Security Policy directive: "img-src 'self' data: github.githubassets.com
identicons.github.com collector.githubapp.com github-cloud.s3.amazonaws.com
*.githubusercontent.com".
Run Code Online (Sandbox Code Playgroud)
注意:这些是正确的,并且在单独的选项卡/窗口中显示正确的图像。
通常,我专用了一个名为 的单独的未合并分支media,其中包含我想在自述文件中使用的任何图像,然后像这样链接它们......
选项 1:<img>使用完整的原始内容 URL。
<img src="https://raw.githubusercontent.com/terrencemm2/terrencemm2/main/assets/azure.png" height=14 />
选项 2:<img>使用相对路径。
<img align="right" width="100" height="100" src="../media/logo.png?raw=true">
选项 3:图像 Markdown 语法,参见https://guides.github.com/features/mastering-markdown/。

markdown github broken-image amazon-s3 github-flavored-markdown