mar*_*and 139
截至目前,相对图像链接在我的存储库和维基中都有用.我正在使用这样的语法:

Run Code Online (Sandbox Code Playgroud)
这是一个例子:
https://github.com/mark-anders/relative-image-url
根据http://blog.rodneyrehm.de/archives/35-Inducing-Data-From-Github.html,使用https://gist.github.com/user/605560c2961cb3025038/raw/b75d2的问题 ... 6e8/img.png
是b75d2...6e8每个文件的部分不同(快速实验确认它是 git blob id)。但是,您可以删除该部分,从而生成指向最新版本的 URL:
https://gist.github.com/user/605560c2961cb3025038/raw/img.png
Run Code Online (Sandbox Code Playgroud)
或者举一个工作示例:
https://gist.githubusercontent.com/cben/46d9536baacb7c5d196c/raw/dodgetocat_v2.png
Run Code Online (Sandbox Code Playgroud)
这也适用于相对路径raw/dodgetocat_v2.png!
但是(截至 2017 年底)github 可以从 2 个 URL 呈现相同的要点:
从https://gist.github.com/cben/46d9536baacb7c5d196c/(带斜杠)查看时,附加相对路径,解析为https://gist.github.com/cben/46d9536baacb7c5d196c/raw/dodgetocat_v2.png — 作品 :-)
从https://gist.github.com/cben/46d9536baacb7c5d196c(无斜杠)查看时,相对路径替换了URL的最后一部分,解析为https://gist.github.com/cben/raw/dodgetocat_v2 .png — 坏了 :-(
[2017 年 12 月更新。以前的原始文件问题用作Content-Type: application/octet-stream和重写src图像的属性camo.githubusercontent.com不再发生,至少对于来自同一主旨的图像不会。]
唉,我们不能只使用第一个 URL 并相信它总是有效。
(您可以使用46d9536baacb7c5d196c/raw/dodgetocat_v2.png仅在没有尾部斜杠的情况下才有效的相对路径,但这也是有问题的想法,而且不太值得 - 并不比完整 URL 更灵活。)
两者都可以通过修复 Content-Type 的代理来解决,例如 Rawgit 或 Bl.ocks.org(不是 Github,不要滥用它们)。不幸的是,Rawgit 不呈现 Markdown,仅按原样提供文件,而 Bl.ocks.org 确实呈现 Markdown,但 URL 结构使得相对链接不起作用。这意味着您可以在 Markdown 中引用完整的外部 URL,也可以在 HTML 中引用 :-(
请参阅https://gist.github.com/cben/46d9536baacb7c5d196c/分叉出您的要点,并通过以下方式查看其 index.html:
| 归档时间: |
|
| 查看次数: |
59770 次 |
| 最近记录: |