有人知道如何在markdown显示本地图像吗?我不想为此设置网络服务器。

我尝试以下markdown,但它不起作用:

![](文件/ \用户形象/ jzhang桌面/孤立。png)


当前回答

最好的解决方案是提供一个相对于md文档所在文件夹的路径。

浏览器在尝试解析本地文件的绝对路径时可能遇到了麻烦。这可以通过通过web服务器访问文件来解决,但即使在这种情况下,图像路径也必须是正确的。

在文档的同一级别设置一个文件夹,包含所有图像,这是最干净和最安全的解决方案。 它将加载到GitHub,本地,本地web服务器。

images_folder/img.jpg  < works


/images_folder/img.jpg  < this will work on webserver's only (please read the note!)

使用绝对路径,图像只能通过如下url访问:http://hostname.doesntmatter/image_folder/img.jpg

其他回答

类unix操作系统的解决方案。

STEP BY STEP :

创建一个名为Images的目录,并放置所有将由Markdown呈现的图像。 例如,将example.png放到Images中。 加载之前位于Images目录下的example.png。

![title](Images/example.png)

注意:图像目录必须位于markdown文本文件的相同目录下,扩展名为.md。

我有一个解决办法:

a)互联网示例:

![image info e.g. Alt](URL Internet to Images.jpg "Image Description")

b)本地图像示例:

![image Info](file:///<Path to your File><image>.jpg "Image Description")
![image Info](file:///C:/Users/<name>/Pictures/<image>.jpg "Image Description")

涡轮字节

据我所知,对于Linux上的VSCode,只有当您将映像放入与.md post文件相同的文件夹中时,本地映像才能正常显示。 即只有! [](image.jpg)或![](。/ image.jpg)将工作。 甚至像![](/home/bala/image.jpg)这样的绝对路径也不能工作。

你可能会发现下面的语法类似于markdown中的引用链接,特别是当你有一个文本有许多相同的图像显示时:

![optional text description of the image][number]

[number]: URL

例如:


![][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

要么将图像放在与markdown文件相同的文件夹中,要么使用图像的相对路径。