Reputation: 28924
Does anyone know how to display a local image in markdown? I don't want to set up a webserver for that.
I try the following in markdown, but it doesn't work:

Upvotes: 910
Views: 1360793
Reputation: 20814
I suspect the path is not correct. As mentioned by user7412219, Ubuntu and Windows deal with path differently. Try to put the image in the same folder as your Notebook and use:

On windows the desktop should be at: C:\Users\jzhang\Desktop
.
Upvotes: 892
Reputation: 2625
I recently needed to add images to a README.md file in Github. The image can be reference via the repository root path.
Note: I used a standard image tag because the markdown syntax doesn't play well with tables.
Github repository structure:
repo/
- src/
- branding/
- README.md
- doc-assets/
- MAB-8942-Before.png
In the README.md file:
<img src="/src/branding/doc-assets/MAB-8942-Before.png" alt="Before image">
Upvotes: 2
Reputation: 31
In my case, I tried a lot of solutions to display an image in my vscode .md reader, but none of them works. But it appears that it only works when you specify the full path to the image from the root for example:

.
The trick is you need to specify / before the letter c of your drive
Upvotes: 3
Reputation: 21
For me working fine with gitlab when I have specified URL to image started from ./
Please double-check that you don't have the space between [] and ()
![img] (URL)
^
Sometimes very confusing.
Upvotes: 2
Reputation: 141
Just add the relative image file route from the markdown file

Upvotes: 14
Reputation: 5075
This worked for me in ubuntu:

Markdown file is in:
/home/gps/Documents/Markdown/
Image file is in:
/home/gps/Pictures/
Upvotes: 9
Reputation: 4691
The following works with a relative path to an image into a subfolder next to the document:

Upvotes: 455
Reputation: 8566
if image has bracket it won't display
.png)
rename the image and remove brackets

Update: if you have spaces in the file path, you should consider renaming it too or if you use JavaScript you can encode it using
encodeURIComponent(imagePath)
Also, always try to save images and files alike with lowercase, please develop that habit, just my personal view though
Upvotes: 22
Reputation: 897
You may find following the syntax similar to reference links in markdown handy, especially when you have a text with many displays of the same image:
![optional text description of the image][number]
[number]: URL
For example:
![][1]
![This is an optional description][2]
[1]: /home/jerzy/ComputerScience/Parole/Screenshot_2020-10-13_11-53-29.png
[2]: /home/jerzy/ComputerScience/Parole/Screenshot_2020-10-13_11-53-30.png
Upvotes: 5
Reputation: 1186
Create a directory named like Images
and put all the images that will be rendered by the Markdown.
For example, put example.png
into Images
.
To load example.png
that was located under the Images
directory before.

Note : Images
directory must be located under the same directory of your markdown text file which has .md
extension.
Upvotes: 91
Reputation: 432
Depending on your tool - you can also inject HTML into markdown.
<img src="./img/Isolated.png">
This assumes your folder structure is:
├── img
└── Isolated.jpg
├── README.md
Upvotes: 12
Reputation: 111
In Jupyter Notebook Markdown, you can use
<img src="RelPathofFolder/File" style="width:800px;height:300px;">
Upvotes: 7
Reputation: 45
just copy the image and then paste it, you will get the output

Upvotes: 2
Reputation: 439
Edited:

tree
├── doc
└── jobsSystemSchema.jpg
├── README.md
markdown file README.md is at the same level as doc directory.
In your case ,your markdown file should be at the same level as the directory files.


Upvotes: 9
Reputation: 2157
To my knowledge, for VSCode on Linux, the local image can be normally displayed only when you put the image into the same folder as your .md
post file.
i.e. only 
or 
will work.
Even the absolute path like 
also doesn't work.
Upvotes: 5
Reputation: 1845
The best solution is to provide a path relative to the folder where the md document is located.
Probably a browser is in trouble when it tries to resolve the absolute path of a local file. That can be solved by accessing the file trough a webserver, but even in that situation, the image path has to be right.
Having a folder at the same level of the document, containing all the images, is the cleanest and safest solution. It will load on GitHub, local, local webserver.
images_folder/img.jpg < works
/images_folder/img.jpg < this will work on webserver's only (please read the note!)
Using the absolute path, the image will be accessible only with a url like this: http://hostname.doesntmatter/image_folder/img.jpg
Upvotes: 25
Reputation: 312
I've had problems with inserting images in R Markdown. If I do the entire URL: C:/Users/Me/Desktop/Project/images/image.png
it tends to work. Otherwise, I have to put the markdown in either the same directory as the image or in an ancestor directory to it. It appears that the declared knitting directory is ignored when referencing images.
Upvotes: 1
Reputation: 1578
Adding a local image worked for me by like so: 
Without the file://
prefix it did not work (Win10, Notepad++ with MarkdownViewer++ addon)
Edit: I found out it also works with html tags, and that is way better:
<img src="file://IMG_20181123_115829.jpg" alt="alt text" width="200"/>
Edit2: In Atom editor it only works without the file://
prefix. What a mess.
Upvotes: 18
Reputation: 9
I got a solution:
a) Example Internet:

b) Example local Image:


TurboByte
Upvotes: -3
Reputation: 654
Either put the image in the same folder as the markdown file or use a relative path to the image.
Upvotes: 1
Reputation: 1296
To add an image in markdown file the .md file and the image should be in the same directory. As in my case my .md file was in doc folder so i also moved the image into the same folder. After that write the following syntax in .md file

like 
This has worked for me.
Upvotes: 32
Reputation: 2519
Another possibility for not displayed local image is unintentional indent of the image reference - spaces before 
.
This makes it 'code block' instead of 'image inclusion'. Just remove the leading spaces.
Upvotes: 4