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

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

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

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


当前回答

您还可以添加带有简单HTML标记的图像:

<p align="center">
  <img src="your_relative_path_here" width="350" title="hover text">
  <img src="your_relative_path_here_number_2_large_name" width="350" alt="accessibility text">
</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

也可以使用相对路径,如

![Alt text](relative/path/to/img.jpg?raw=true "Title")

还可以使用所需的.fileExtetion尝试以下操作:

![plot](./directory_1/directory_2/.../directory_n/plot.png)

尝试此标记:

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

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

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

非常简单:可以使用Ctrl+C/V完成

这里的大多数答案都是直接或间接地将图像上传到其他地方,然后提供链接。

只需复制任何图像并在编辑Readme.md时粘贴即可完成

复制图像-您只需单击图像文件并使用Ctrl+C,也可以使用剪切工具将截图图像复制到剪贴板然后,您可以在编辑Readme.md时简单地按Ctrl+V

Guithub将自动将其上传到user-images.githubusercontent.com,并在那里插入指向它的链接

我们可以简单地做到这一点,

在GitHub上创建新问题在Issue的body div上拖放图像

几秒钟后,将生成一个链接。现在,复制链接或图像URL并使用任何支持的平台。