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

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

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

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


当前回答

有两种简单的方法可以做到这一点,

1) 使用HTML img标记,

2) ![](保存图像的路径/image-name.png)

打开图像时,可以从浏览器中的URL复制路径。可能会出现间距问题,因此请确保在路径或图像名称add->%20中是否有空格b/w两个字。就像浏览器一样。

如果你想了解更多,可以查看我的github->https://github.com/adityarawat29

其他回答

我只是在已经接受的答案上延伸或添加一个例子。

一旦您将图像放到Github存储库中。

然后:

在浏览器上打开相应的Github repo。导航到目标图像文件,然后在新选项卡中打开图像。复制url最后将url插入到以下模式![替换文本](https://raw.githubusercontent.com/username/projectname/branch/path/to/img.png)

就我的情况而言

![在一张图片中](https://raw.githubusercontent.com/shadmazumder/Xcode/master/InOnePicture.png)

哪里

shadmazumder是我的用户名Xcode是项目名称master是分支InOnePicture.png是图像,在我的情况下,InOnePicture.php位于根目录中。

此答案也可在以下位置找到: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文件中包含一些图像。我不知道该怎么做这样做。

我创建了一个小向导,允许您为GitHub存储库的自述文件创建和自定义简单的图像库:请参阅ReadmeGalleryCreatorForGitHub。

该向导利用了GitHub允许img标签出现在README.md中的事实。此外,该向导还利用了将图像上传到GitHub的流行技巧,方法是将图像拖放到问题区域(如本主题的一个答案中所述)。

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

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

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

你可以这样做:

git checkout --orphan assets
cp /where/image/currently/located/on/machine/diagram.png .
git add .
git commit -m 'Added diagram'
git push -u origin assets

然后,您可以在README文件中引用它,如下所示:

![diagram](diagram.png)