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


当前回答

首先,在本地repo的根目录下创建一个目录(文件夹),其中将包含您想要添加的屏幕截图。让我们把这个目录的名称称为屏幕截图。将你想要添加的图片(JPEG、PNG、GIF等)放到这个目录中。

Android Studio工作空间截图

其次,您需要将每个图像的链接添加到README中。所以,如果我的截图目录中有命名为1_ArtistsActivity.png和2_AlbumsActivity.png的图像,我将像这样添加它们的链接:

 <img src="screenshots/1_ArtistsActivity.png" height="400" alt="Screenshot"/> <img src=“screenshots/2_AlbumsActivity.png" height="400" alt="Screenshot"/>

如果你想让每个截图在单独的行上,把它们的链接写在单独的行上。但是,最好将所有链接写在一行中,仅用空格分隔。它可能看起来不太好,但通过这样做,GitHub会自动为你安排它们。

最后,提交您的更改并发布它!

其他回答

从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上的自述。

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

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

比添加URL简单多了 只要上传一张图片到同一个存储库, 如:

(截图)! (screenshot.png)

对我来说,相对路径非常有效。

我是怎么做到的: 在我当前的md文件中,我想使用来自另一个目录的图片,我使用了这样的相对路径-考虑以下点。

Md文件loc: base dir -> _post -> current_file.md

&图片文件loc,我想使用:基础dir -> _asset -> picture_to_use.jpeg

我使用的语句是在current_file上。md文件:

![your-pic-caption-name](../_asset/picture_to_use.jpeg)

注意-在此之前,我使用的是direct _asset,但理想情况下,它从../_asset/and-so-no开始

参考资料- https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-readmes

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

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

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