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

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

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

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


当前回答

您还可以像任何其他格式一样在markdown文件中插入动画SVG图像。它可以很好地替代GIF图像。

![image description](relative/path/in/repository/to/image.svg)
OR
<img src="relative/path/in/repository/to/image.svg" width="128"/>

示例(假设图像位于存储库中的assets目录中):

![My animated logo](assets/my-logo.svg)

结果:


要使用基于GitHub深色/浅色主题的不同图像,请参阅本文。

其他回答

基本语法

![myimage-alt-tag](url-to-image)

在这里:

my image alt标记:如果未显示图像,将显示的文本。图像的url:无论您的图像资源是什么。图像的URI

例子:

![stack Overflow](http://lmsotfy.com/so.png)

如下所示:

此答案也可在以下位置找到: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

只需在里面的README.md文件中写下代码[Anyname](图像路径)

![Screenshot](screenshot1.png)

从上传文件选项将图像添加到存储库中,然后添加到README文件中

![Alt text]("enter repository image URL here") 

您还可以像任何其他格式一样在markdown文件中插入动画SVG图像。它可以很好地替代GIF图像。

![image description](relative/path/in/repository/to/image.svg)
OR
<img src="relative/path/in/repository/to/image.svg" width="128"/>

示例(假设图像位于存储库中的assets目录中):

![My animated logo](assets/my-logo.svg)

结果:


要使用基于GitHub深色/浅色主题的不同图像,请参阅本文。