在GitHub上将图像添加到README.md
本文翻译自:Add images to README.md on GitHub
Recently I joined GitHub . 最近我加入了GitHub 。 I hosted some projects there. 我在那里举办了一些项目。
I need to include some images in my README File. 我需要在README文件中包含一些图像。 I don't know how to do that. 我不知道该怎么做。
I searched about this, but all I got was some links which tell me to "host images on web and specify the image path in README.md file". 我搜索了这个,但我得到的只是一些链接告诉我“在网络上托管图像并在README.md文件中指定图像路径”。
Is there any way to do this without hosting the images on any third-party web hosting services? 如果没有在任何第三方网络托管服务上托管图像,有没有办法做到这一点?
#1楼
参考:https://stackoom.com/question/yokF/在GitHub上将图像添加到README-md
#2楼
Try this markdown: 试试这个降价:
![alt text](http://url/to/img.png)
I think you can link directly to the raw version of an image if it's stored in your repository. 我认为如果图像存储在您的存储库中,您可以直接链接到图像的原始版本。 ie 即
![alt text](https://raw.githubusercontent.com/username/projectname/branch/path/to/img.png)
Edit: just noticed comment linking to article which suggests using gh-pages. 编辑:只是注意到链接到文章的评论,建议使用gh页面。 Also, relative links can be a better idea than the absolute URLs I posted above. 此外,相对链接可能比我上面发布的绝对URL更好。
#3楼
- You can create a New Issue 您可以创建新问题
- upload(drag & drop) images to it 上传(拖放)图像到它
- Copy the images URL and paste it into your README.md file. 复制图像URL并将其粘贴到README.md文件中。
here is a detailed youTube video explained this in detail: 这是一个详细的youTube视频详细解释了这个:
https://www.youtube.com/watch?v=nvPOUdz5PL4 https://www.youtube.com/watch?v=nvPOUdz5PL4
#4楼
I usually host the image on the site, this can link to any hosted image. 我通常在网站上托管图片,这可以链接到任何托管图像。 Just toss this in the readme. 只是在自述文件中抛出这个。 Works for .rst
files, not sure about .md
适用于.rst
文件,不确定.md
.. image:: https://url/path/to/image
:height: 100px
:width: 200 px
:scale: 50 %
#5楼
I need to include some images in my README File. 我需要在README文件中包含一些图像。 I don't know how to do that. 我不知道该怎么做。
I created a small wizard that allows you to create and customize simple image galleries for your GitHub repository's readme: See ReadmeGalleryCreatorForGitHub . 我创建了一个小向导,允许您为GitHub存储库的自述文件创建和自定义简单的图像库:请参阅ReadmeGalleryCreatorForGitHub 。
The wizard takes advantage of the fact that GitHub allows img tags to occur in the README.md
. 该向导利用了GitHub允许img标签出现在README.md
中的README.md
。 Also, the wizard makes use of the popular trick of uploading images to GitHub by drag'n'dropping them in the issue area (as already mentioned in one of the answers in this thread). 此外,该向导利用了将图像上传到GitHub的流行技巧,方法是将它们拖放到问题区域(如本线程中的一个答案中所述)。
#6楼
您也可以使用相对路径
![Alt text](relative/path/to/img.jpg?raw=true "Title")