Recently I joined GitHub. I hosted some projects there.
I need to include some images in my README File. I don't know how to do that.
I searched about this, but all I got was some links which tell me to "host images on web and specify the image path in README.md file".
Is there any way to do this without hosting the images on any third-party web hosting services?
I created a small wizard that allows you to create and customize simple image galleries for your GitHub repository's readme: See ReadmeGalleryCreatorForGitHub.
The wizard takes advantage of the fact that GitHub allows img tags to occur in the
README.md
. Also, the wizard makes use of the popular trick of uploading images to GitHub by drag'n'dropping them in the issue area (as already mentioned in one of the answers in this thread).In case you need to upload some pictures for documentation, a nice approach is to use git-lfs. Asuming that you have installed the git-lfs follow these steps:
Intialize git lfs for your each image type:
Create a folder that will be used as image location eg.
doc
. On GNU/Linux and Unix based systems this can be done via:Copy paste any images into doc folder. Afterwards add them via
git add
command.Commit and push.
The images are publicly available in the following url:
https://media.githubusercontent.com/media/^github_username^/^repo^/^branch^/^image_location in the repo^
Where: *
^github_username^
is the username in github (you can find it in the profile page) *^repo_name^
is the repository name *^branch^
is the repository branch where the image is uploaded *^image_location in the repo^
is the location including the folder that the image is stored.Also you can upload the image first then visit the location in your projects github page and navigate through until you find the image then press the
download
button and then copy-paste the url from the browser's address bar.Look this from my project as reference.
Then you can use the url to include them using the markdown syntax mentioned above:
Eg: Let us suppose we use this photo Then you can use the markdown syntax:
I am just extending or adding an example to the already accepted answer.
Once you have put the image on your Github repo.
Then:
![alt text](https://raw.githubusercontent.com/username/projectname/branch/path/to/img.png)
On my case it is
![In a single picture](https://raw.githubusercontent.com/shadmazumder/Xcode/master/InOnePicture.png)
Where
shadmazumder
is myusername
Xcode
is theprojectname
master
is thebranch
InOnePicture.png
is theimage
, On my caseInOnePicture.png
is in the root directory.I wanted to update this using ZenHub, since GitHub and ZenHub have changed their graphical layouts.
If you install ZenHub and allow access to your GitHub, then you can navigate to the ZenHub tab once in your repo and open a new issue.
This is an updated version of Ahmad Amji's YouTube video posting.
Step 1:
Step 2: From there you can open an attachment.
Step 3: And then from there you can use the link generated automatically. This way you don't have to bother with creating a new repo just for images.
Then use the standard MarkDown syntax with the URL provided.
Step 4
Step 5 Don't forget to close the issue draft and not actually submit it. The image URL should still work properly!
Many of the posted solutions are incomplete or not to my taste.
My preferred solution, inspired by this gist, is to use an assets branch with permalinks to specific revisions.
Construct a "permalink" to this revision of the image, and wrap it in Markdown:
![Cat](https://raw.githubusercontent.com/{user}/{repo}/{sha}/cat.png)
e.g.
![Cat](https://raw.githubusercontent.com/paulmelnikow/zsh-startup-timer/3923c60fc66d4223ccf063d169ccf2ff167b1270/cat.png)
To always show the latest image on the assets branch, use
assets
in place of the sha:![Cat](https://raw.githubusercontent.com/{user}/{repo}/assets/cat.png)
It's much simpler than that.
Just upload your image to the repository root, and link to the filename without any path, like so: