最近我加入了GitHub。我在那里主持了一些项目。

我需要在README文件中包含一些图像。我不知道该怎么做。

我搜索了一下,但得到的只是一些链接,告诉我“在web上托管图像并在README.md文件中指定图像路径”。

是否有任何方法可以在不在任何第三方网络托管服务上托管图像的情况下做到这一点?


当前回答

您也可以将图像放置在自述文件中的适当部分。

其他回答

这个对我有用!!!。

![alt text](https://github.com/[username]/[reponame]/blob/[branch]/image.jpg?raw=true)

alt text是在图像URL不存在的情况下要显示的可选文本。

user_name是您的GitHub用户名。reponame是您的GitHub repo名称。

最新的

Wiki可以显示PNG、JPEG或GIF图像

现在您可以使用:

[[https://github.com/username/repository/blob/master/img/octocat.png|alt=octocat]]

-OR-

遵循以下步骤:

在GitHub上,导航到存储库的主页面。在存储库名称下,单击Wiki。使用wiki侧栏,导航到要更改的页面,然后单击“编辑”。在wiki工具栏上,单击“图像”。在“插入图像”对话框中,键入图像URL和替代文本(搜索引擎和屏幕阅读器使用)。单击“确定”。

参考文件。

尝试此标记:

![alt text](http://url/to/img.png)

我认为,如果图像存储在存储库中,您可以直接链接到原始版本的图像。即

![alt text](https://github.com/[username]/[reponame]/blob/[branch]/image.jpg?raw=true)

用桌子突出,这会给它带来独特的魅力

表语法为:

按符号分隔每个列单元格|

表格标题(第一行)由第二行由---

|第1列|第2列||------------|-------------||图像1 |图像2|

输出

现在,如果使用两个图像,只需在图像1和图像2处放置<img src=“url/relativePath”>

注意:如果使用多个图像只是包含更多列,则可以使用width和height属性使其看起来可读。

实例

|第1列|第2列||------------|-------------||<img src=“https://media.wired.com/photos/5926db217034dc5f91becd6b/master/w_582,c_limit/so-go-s.jpg“width=”250“>|<img src=”https://mk0jobadderjftub56m0.kinstacdn.com/wp-content/uploads/stackoverflow.com-300.jpg“width=”250“>|

间距无关紧要

输出图像

帮助人:adam-p

此答案也可在以下位置找到:https://github.com/YourUserAccount/YourProject/blob/master/DirectoryPath/ReadMe.md

使用以下方式显示回购中的图像:

前置域:https://raw.githubusercontent.com/

附加标志:?消毒=真&原始=真

使用<img/>标记

Eample url works for svg, png, and jpg using:

域名:raw.githubusercontent.com/用户名:YourUserAccount/回购:YourProject/分行:YourBranch/路径:DirectoryPath/文件名:example.png

适用于SVG、PNG和JPEG

 - `raw.githubusercontent.com/YourUserAccount/YourProject/YourBranch/DirectoryPath/svgdemo1.svg?sanitize=true&raw=true`

使用后显示的工作示例代码如下:

**raw.githubusercontent.com**:
<img src="https://raw.githubusercontent.com/YourUserAccount/YourProject/master/DirectoryPath/Example.png?raw=true" />

<img src="https://raw.githubusercontent.com/YourUserAccount/YourProject/master/DirectoryPath/svgdemo1.svg?sanitize=true&raw=true" />

raw.githubusercontent.com:

谢谢:- https://stackoverflow.com/a/48723190/1815624- https://github.com/potherca-blog/StackOverflow/edit/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/readme.md