Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add images to README.md on BitBucket

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

UPDATE:

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

I have stored readme.md file and an image file in a BitBucket repo as follows:

  • readme.md
  • images/
    • scheme.jpg

I reference the image from readme.md as follows:

![Scheme](images/scheme.jpg)

like image 853
Danny Dan Avatar asked Feb 27 '15 13:02

Danny Dan


People also ask

How do I add an image to bitbucket?

You can upload images anywhere you see the markup toolbar ? just click the image button to get started. Select an image from the file chooser or drag one to the dialog, or you can drag an image right into the comment box! We'll upload your image and insert the link into your markup, ready to be seen.

Can you add images to a Markdown file?

You can add images to Markdown using the [alt text](image_url) syntax.


2 Answers

Update 2016-12-14

This is fixed now, please see the resolved status of this issue: 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.

Old Answer

At the moment, this is not possible. BitBucket does not support relative links to images in 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

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).

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.

like image 106
nwinkler Avatar answered Sep 18 '22 05:09

nwinkler


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


According to Altassian it'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.

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

[Your Link Text](https://bitbucket.org/username/reponame/raw/master/path/to/image.jpg) 
like image 33
Sébastien Dawans Avatar answered Sep 21 '22 05:09

Sébastien Dawans