VSCode & local image in markdown

I asked about this a year ago, but there was not really a solution to my problem…

I’m trying to insert an image into a markdown cell of a Jupyter Notebook in VSCode. The following code does not work, for some weird reason:

<img src="../figs/WaveNet-1.svg" width="25%" height = "25%" />

Here, the image is found in the figs directory, which is a subdirectory of the parent directory of where the notebook is located.

However, it seems like if I move the image file to the same directory as the notebook, and change the insertion code to:

<img src="WaveNet-1.svg" width="25%" height = "25%" />

then it sort of works… (“sort of”… I had to open the markdown cell and execute it several times before the image showed up… and this makes the directory cluttered).

Question: Is this a bug in VSCode/Jupyter notebook?

[If I instead create a subdirectory figs under the location of the notebook and write:

<img src="figs/WaveNet-1.svg" width="25%" height = "25%" />

this also works. I want to put figures in a given folder to avoid clutter. I’m surprised that I cannot use the "../figs/...." syntax. ]

I have an impression that jupyter can only see files in children directories. A quick search reveals this confirmation

I am not sure if I understood your question properly though. I mean I did not get where is the root of your jupyter notebook.

1 Like

I am modifying a Jupyter notebook that I ran in the past using IJulia, in my web browser. In the original notebook, there was no problem in using

<img src="../figs/WaveNet-1.svg" width="25%" height = "25%" />

But this file syntax does not work with Jupyter notebook in VSCode. I do not think this is because VSCode is confused with the directory it is in – I also tried to specify the full path in the text string above ("C://...."), but that didn’t work. So either there is a reduced functionality in VSCode (compared to IJulia + web browser), or some changes has been made.

I can probably live with putting figures in sub-folders, but I don’t like it… I try to have (LaTeX) documents (docs), figures (figs), and notebooks (nbs) in parallel subfolders, and I may have to change that.

This has nothing to do with julia.
You may want to open a bug report on github: vscode-jupyter.

1 Like

I will do so.