git - 如何在同一存储库的 README Markdown 文件中显示(链接到/超链接)Azure DevOps Git 存储库中的图像?

标签 git hyperlink version-control azure-devops markdown

我们的团队希望在我们的 Git 存储库中的一些 Markdown 文件文档中包含图像。我们还想将图像存储在 Git 存储库中并将它们视为源。因为它们是二进制文件,我们可以将它们存储在单独的 Git 存储库中。但是,我们更愿意将图像保留在源中,而不必将它们放在其他某种类型的存储中(即除了 repo 之外的其他存储)。

在 Markdown 中,我们希望能够链接到图像,以便它们显示在 Azure DevOps 预览中(就像它们是常规 HTML 页面一样)。

是否有可以在 Azure DevOps 中的 Markdown 文件中使用的链接格式来显示我们的图像?

我们尝试简单地在 Markdown 中放置一个“img”标签,并将其指向 Azure DevOps Git 存储库中文件的 URI。这不起作用。

<img src="https://anyaccount.visualstudio.com/repos/_git/ourRepo?path=%2FSrc%2FDocumentation%2FImages%2FImage.PNG&version=GBmaster" alt="drawing" style="width:541px" />

我们希望能够使用图像的完整 URI(即不是相对链接),以便它不仅显示在 Azure DevOps 的“预览” View 中,而且允许我们将 Markdown 文件转换为其他格式(例如 HTML , MediaWiki) 也将正确显示图像。

最佳答案

尝试使用 Git Items API .我能够使用如下 URL 以这种方式直接链接到一个 repo 项目:

https://{organization}.visualstudio.com/{project}/_apis/git/repositories/{repo}/Items?path=path=%2Ftip.png&versionDescriptor%5BversionOptions%5D=0&versionDescriptor%5BversionType%5D=0&versionDescriptor%5Bversion%5D=master&download=false&resolveLfs=true&%24format=octetStream&api-version=5.0-preview.1

示例:

存储在 repo 中的图像:

enter image description here

然后在 README.md 中使用 API 引用它:
<img src="https://{organization}.visualstudio.com/{project}/_apis/git/repositories/{repo}/Items?path=%2Ftip.png&version%5D=master&download=false&resolveLfs=true&%24format=octetStream&api-version=5.0-preview.1"/>

然后它显示在自述文件中:

enter image description here

关于git - 如何在同一存储库的 README Markdown 文件中显示(链接到/超链接)Azure DevOps Git 存储库中的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54204452/

相关文章:

git - Bitbucket 443 网络在不同网络上无法访问

ios - href=电话 :555 link not working in mobile safari

hyperlink - 使用JS将单元格中的链接复制到另一个工作表时保留超链接URL

git - 无限期地保持 Git Reflog?

git - 如果从未提交过,您可以撤消 'git reset --hard HEAD' 吗?

git - 在 Github 上更改 PR 的源代码分支

git - 看不到远程分支

git - 一个提交对象怎么可能有 2 个作者?

php - 加密mysql数据并通过超链接,然后在下一页解密?

git 假设不变的含义