Embedding images inside a GitHub wiki (gollum) repository?

前端 未结 15 688
时光取名叫无心
时光取名叫无心 2021-01-30 00:43

The Github wikis are backed by a separate git repository then the main project repository.

This post by the Github team makes it sound like you should be able to link to

相关标签:
15条回答
  • 2021-01-30 01:14

    James' URL format did not work for me, perhaps it has been changed. I have used:

    https://github.com/username/project/wiki/pathtoimage/image.extension

    Where pathtoimage is optional.

    0 讨论(0)
  • 2021-01-30 01:14

    To embed an external image thumbnail, use the following, ![Image](<external link to the image>)

    0 讨论(0)
  • 2021-01-30 01:16

    Relative path work for me like this:

    home page of the wiki:

    ![text](wiki/images/someimage.png)
    

    sub page of the wiki:

    ![text](images/someimage.png)
    

    Note that when doing a preview the image will not show, I had save it.

    0 讨论(0)
  • 2021-01-30 01:23

    None of answers seem to work when adding an image in readme.md. I've got a solution though:

    If the URL of the image is:

    https://github.com/Username/Repository-Name/blob/master/Directory-Inside-Repository/image.png
    

    Replacing blob with raw gives you the URL of the raw image:

    https://github.com/Username/Repository-Name/raw/master/Directory-Inside-Repository/image.png
    

    Now, you'd embed the image using normal markdown:

    ![Image Alt](https://github.com/Username/Repository-Name/raw/master/Directory-Inside-Repository/image.png)
    

    UPDATE: As of now, GitHub also serves raw images from a different sub-domain raw.github.com. So, you can also use:

    https://raw.github.com/Username/Repository-Name/master/Directory-Inside-Repository/image.png
    

    EXAMPLE: https://raw.github.com/Automattic/liveblog/master/screenshot-1.png

    0 讨论(0)
  • 2021-01-30 01:25

    For viewers wishing to view images on a github wiki I've found the following method to work:

    • Go to the "Git Access" tab inside the wiki page of your repository and retrieve the SSH path which should be some thing like: git@github.com:USER/REPO.wiki.git where USER is your account name and REPO is the repository name.
    • On your local machine use whichever Git command line tool you wish to cd into your local directory of choice and get the repository via

      git clone git@github.com:USER/REPO.wiki.git

    • Now within this repository create an image directory, I'll call it "images" and put whatever images you want into the directory

    • And then push your wiki git directory to github
    • You will not be able to physically see the images in say the "Pages" tab, but if you simply reference the images in a local link you should be able to see them. Example with Markdown below:

      ![Alt attribute text Here](images/YOURIMAGE.ext)

    • You may also embed the image as a link itself by wrapping it further like so:

      [![Alt attribute text Here](images/YOURIMAGE.ext)](http://Yoursite.com)

    You can also add subdirectories within your local copy to help organize the wiki since the "pages" tab simply lists them out. Keep in mind, however, that even when the new directory is pushed the "pages" tab doesn't list the directory.

    0 讨论(0)
  • 2021-01-30 01:25

    Many of the answers didn't work for me, here's what finally worked:

    ![](../raw/master/Images/ImportantImage.png)
    

    Using the "Markdown" editor mode and a sub-page such as:

    https://github.com/project/repo/wiki/MyPage
    

    -John

    0 讨论(0)
提交回复
热议问题