是否可以在一个GitHub存储库的README文件中放置一个截图?语法是什么?


当前回答

从2021年3月起,现在支持:

将文件附加到标记文件

You can now attach files, including images, to markdown files while you're editing them in the web. This works just like file attachments in issues and pull requests and supports the same file types. Just drag and drag, click and select, or paste. Note: If you add an image to a markdown file, anyone can view the anonymized image URL without authentication, even if the markdown file is in a private repository. To keep images private, serve them from a private network or server that requires authentication. For more information on anonymized URLs see "About anonymized image URLs".

其他回答

尽管已经有了一个公认的答案,我想添加另一种方式来上传图片到GitHub上的自述。

你需要在你的回购中制造问题 拖放在评论区你的图像 图像链接生成后,将其插入到自述文件中

更多细节你可以在这里找到

对我来说,最好的办法是

用github上的存储库创建一个新问题,然后以gif格式上传文件。要将视频文件转换为gif格式,您可以使用这个网站http://www.online-convert.com/ 提交新创建的问题。 复制上传文件的地址 最后在你的README文件中放入!

希望这能有所帮助。

[截图](截图.png)就像上面提到的那样。将截图.png替换为您在存储库中上传的图像的名称。

但当你上传图片时,这里有一个新手提示(我自己也犯了这个错误):

确保映像名称不包含空格。我的原始图片被保存为“截图日月年id.png”。如果您不将名称更改为类似contenttofimage .png的名称,那么它将不会作为图像出现在自述文件中。

如果您使用Markdown (README.md):

如果你有图片在你的repo,你可以使用一个相对URL:

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

如果您需要嵌入托管在其他地方的图像,则可以使用完整的URL

![Alt text](http://full/path/to/img.jpg "Optional title")

GitHub建议使用带?raw=true参数的相对链接,以确保fork回购点正确。

raw=true参数的存在是为了确保你链接到的图像将会按原样呈现。这意味着只有图像将被链接,而不是相应文件的整个GitHub界面。更多细节请看这条评论。

请看一个例子:https://raw.github.com/altercation/solarized/master/README.md

如果你使用svg,那么你也需要将sanitize属性设置为true: ?raw=true&sanitize=true。(感谢@EliSherer)

另外,README文件中有关相对链接的文档:https://help.github.com/articles/relative-links-in-readmes

当然还有降价文档:http://daringfireball.net/projects/markdown/syntax

此外,如果您创建了一个新的分支屏幕截图来存储图像,您可以避免它们在主工作树中

然后你可以使用以下方法嵌入它们:

![Alt text](/../<branch name>/path/to/image.png?raw=true "Optional Title")

方法1->降价方式

![Alt Text](https://raw.github.com/{USERNAME}/{REPOSITORY}/{BRANCH}/{PATH})

方法2->HTML方式

<img src="https://link(format same as above)" width="100" height="100"/>

or

<img src="https://link" style=" width:100px ; height:100px " />

如果你不想样式你的图像,即调整大小,删除样式部分