[英]How to display images in Markdown files on Github?
I want to display some images in a Markdown file on Github.我想在 Github 上的 Markdown 文件中显示一些图像。 I found it works this way:
我发现它是这样工作的:
![Figure 1-1](https://raw.github.com/username/repo/master/images/figure 1-1.png "Figure 1-1")
But i need to collaborate with others so i don't want the username and repo name hard coded .但我需要与其他人合作,所以我不想硬编码用户名和回购名称。
I tried to use this:我试着用这个:
![Figure 1-1](images/figure 1-1.png "Figure 1-1")
It works on my local disk but not work on Github.它适用于我的本地磁盘,但不适用于 Github。
Is there anyone knows about this issue?有没有人知道这个问题?
I found the answer myself.我自己找到了答案。
Just simply append ?raw=true to the image url will make the trick:只需简单地将?raw=true附加到图像 url 就可以了:
![](images/table 1-1.png?raw=true)
I just had the same issue and it turned out to be caused by the space in the URL.我刚刚遇到了同样的问题,结果是由 URL 中的空格引起的。 Manually URL encoding the space as
%20
fixed it.手动 URL 编码空间为
%20
修复它。
So using your example I changed:所以使用你的例子我改变了:
![](images/table 1-1.png)
to:到:
![](images/table%201-1.png)
2021 Edit: Thanks Emilio for pointing out that the GitHub flavored markdown spec has been updated to allow spaces in filenames when the filename is enclosed inside "pointy" (angle) brackets: 2021 年编辑:感谢 Emilio 指出 GitHub 风格的降价规范已更新,当文件名包含在“尖”(尖角)括号内时,文件名中允许有空格:
The destination can only contain spaces if it is enclosed in pointy brackets
Example 498
[link](</my uri>) --> <p><a href="/my%20uri">link</a></p>
Ref: https://github.github.com/gfm/#example-498 (scroll up for description)参考: https : //github.github.com/gfm/#example-498 (向上滚动描述)
This works with images too so we can now also use:这也适用于图像,因此我们现在也可以使用:
![](<images/table 1-1.png>)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.