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


当前回答

使用位于/screen-shots目录中的图像。外部的<div>允许图像被定位。填充是使用<img width="desired-padding" height="0">实现的。

<div align="center">
        <img width="45%" src="screen-shots/about.PNG" alt="About screen" title="About screen"</img>
        <img height="0" width="8px">
        <img width="45%" src="screen-shots/list.PNG" alt="List screen" title="List screen"></img>
</div>

其他回答

Markdown: !黑“更加铝(http://url/to/img.png)

创建一个关于添加图像的问题 通过拖放或文件选择器添加图像 然后复制图像源 现在添加![截图](http://url/to/img.png)到您的README。md文件

完成了!

或者,你也可以使用一些图像托管网站,如imgur,并获得它的url,并将其添加到你的README。Md文件或者你也可以使用一些静态文件托管。

样品的问题

下面一行应该就是你要找的内容

如果文件在存储库中

![ScreenShot](https://raw.github.com/{username}/{repository}/{branch}/{path})

如果您的文件在其他外部url

![ScreenShot](https://{url})

我发现在我的repo图像的路径是不够的,我必须链接到raw.github.com子域上的图像。

网址格式https://raw.github.com/{USERNAME}/{REPOSITORY}/{BRANCH}/{PATH}

降价示例![设置窗口](https://raw.github.com/ryanmaxwell/iArrived/master/Screenshots/Settings.png)

从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".

我在谷歌上搜索了一些类似的问题,没有看到任何关于我的问题的答案,而且它非常简单/容易解决。

云存储——在readme中处理图像的方法略有不同

就像OP一样,我想在我的Github README中有一张图像,并且,知道这样做的Markdown语法,输入它:

![My Image](https://storage.cloud.google.com/${MY_BUCKET}/${MY_IMAGE}

您需要完成上面的实际替换(例如MY_IMAGE=image.jpg)才能使其工作。

但是,等待…失败——没有实际渲染的照片!和链接是完全由谷歌存储!

Github迷彩-匿名图像

Github匿名托管你的图片,耶!但是,这就为谷歌存储资产带来了一个问题。您需要从谷歌云控制台获取生成的url。

我相信有一个更流畅的方法,但是,只需访问您给定的URL端点并复制长URL。细节:

指令

访问您的存储控制台:https://console.cloud.google.com/storage/browser/${MY_BUCKET}?project=${MY_PROJECT} 点击你想要在Github中显示的图像(这会弹出“对象详细信息”页面) 复制pasta的URL(以https开始,而不是gs)到一个新的浏览器选项卡/窗口 复制pasta新生成的URL -它应该更长-从你的新浏览器选项卡/窗口到你的Github README文件

希望这有助于加快和澄清这个问题的其他人。