git 将图片添加到 BitBucket 上的 README.md

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28766550/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:58:14  来源:igfitidea点击:

Add images to README.md on BitBucket

imagegitmarkdownbitbucket

提问by Danny Dan

Can I somehow reference the image from readme.mdfile so that it renders when viewed in BitBucketdirectly from project (without hosting the image elsewhere on web) ?

我可以以某种方式从readme.md文件中引用图像,以便它在BitBucket 中直接从项目中查看时呈现(无需在网络上的其他地方托管图像)?

UPDATE:

更新:

The issuewas resolved so it's working now as it was explained in the question:

问题已解决,因此它现在可以正常工作了,正如问题中所解释的那样:

I have stored readme.mdfile and an image file in a BitBucketrepo as follows:

readme.mdBitBucket存储库中存储了文件和图像文件,如下所示:

  • readme.md
  • images/
    • scheme.jpg
  • 自述文件
  • 图片/
    • 方案.jpg

I reference the image from readme.mdas follows:

我参考以下图片readme.md

![Scheme](images/scheme.jpg)

![Scheme](images/scheme.jpg)

采纳答案by nwinkler

Update 2016-12-14

更新 2016-12-14

This is fixed now, please see the resolvedstatus of this issue: https://bitbucket.org/site/master/issues/6315/relative-urls-in-readmemd-files-only-work

现在已修复,请查看resolved此问题的状态:https: //bitbucket.org/site/master/issues/6315/relative-urls-in-readmemd-files-only-work

You can now use

您现在可以使用

![Scheme](images/scheme.jpg)

to refer to images in your repo using relative links.

使用相对链接引用您的 repo 中的图像。

Old Answer

旧答案

At the moment, this is not possible. BitBucket does not support relative links to images in markdown.

目前,这是不可能的。BitBucket 不支持 Markdown 中图像的相对链接。

The following issue in BitBucket's issue tracker has more info on this, its current status (2015-02-27) is open: https://bitbucket.org/site/master/issue/6315/relative-urls-in-readmemd-files-only-work

BitBucket 的问题跟踪器中的以下问题有更多信息,其当前状态 (2015-02-27) 是开放的https: //bitbucket.org/site/master/issue/6315/relative-urls-in-readmemd-仅文件工作

The BitBucket team have indicated on the ticket that they intend to fix this "in the coming quarters" (comment from 2014-12-19: https://bitbucket.org/site/master/issue/6315/relative-urls-in-readmemd-files-only-work#comment-14400835).

BitBucket 团队在票证上表示他们打算“在未来几个季度”解决这个问题(2014-12-19 的评论:https: //bitbucket.org/site/master/issue/6315/relative-urls-in -readmemd-files-only-work#comment-14400835)。

The ticket contains a couple of (ugly) workarounds, using a combination of two links, where one works locally, and one on the web site (https://bitbucket.org/site/master/issue/6315/relative-urls-in-readmemd-files-only-work#comment-15852315) as well as some other possible solutions, none of which are particularly nice or reliable.

该票包含几个(丑陋的)解决方法,使用两个链接的组合,一个在本地工作,一个在网站上(https://bitbucket.org/site/master/issue/6315/relative-urls- in-readmemd-files-only-work#comment-15852315)以及其他一些可能的解决方案,但没有一个特别好或可靠。

回答by Sébastien Dawans

Update: please see the accepted answer as the issue is now fixed and this workaround is obsolete.

更新:请查看已接受的答案,因为问题现已解决,并且此解决方法已过时。



According to Altassianit's not supported so you need to use absolute URLs. You can use branch names instead of commit hash to allow the link to be updated if you change the image in later commits.

根据Altassian的说法,它不受支持,因此您需要使用绝对 URL。如果您在以后的提交中更改图像,您可以使用分支名称而不是提交哈希来更新链接。

For example, here is taking the /path/to/image.jpg, from the masterbranch:

例如,这里/path/to/image.jpgmaster分支中取出, :

[Your Link Text](https://bitbucket.org/username/reponame/raw/master/path/to/image.jpg)

回答by GG86

Don't use any spaces in image or directory names. For example: ![](images/app screens/screen 10.png) should become Sub-folders can be used for other md documents. Again, I recommend replacing spacing with dashed even in folders that only contain md or other files.

Not sure about this, but the starting document might need to be named README.md, and images might need to be in a top-level folder named "images" in the same directory as the README.md file.

Finally, please refresh your page when you see a broken image link. I noticed some images would load and others were not even though they were in the same format.

不要在图像或目录名称中使用任何空格。例如:![](images/appscreens/screen 10.png) 应该成为子文件夹,可以用于其他md文件。同样,我建议即使在仅包含 md 或其他文件的文件夹中也用虚线替换间距。

对此不确定,但起始文档可能需要命名为 README.md,并且图像可能需要位于与 README.md 文件相同的目录中名为“images”的顶级文件夹中。

最后,当您看到损坏的图片链接时,请刷新您的页面。我注意到有些图像会加载,而有些则不会,即使它们的格式相同。

For more Info, please, have a look at Atlassian: Add images to a wiki pageand russells-rocksauce answer in bitbucket issues forum

有关更多信息,请查看Atlassian:将图像添加到 wiki 页面bitbucket 问题论坛中的 russells-rocksauce 答案

回答by Srikrushna

It's very simple

这很简单

Just upload your image to the repository root, and link to the filename without any path, like so:

只需将您的图像上传到存储库根目录,并链接到没有任何路径的文件名,如下所示:

![your_image_name](your_image_name.png)