Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown image links with relative paths that navigate back - not displayed in Markdown Preview #82021

Closed
alexbarten opened this issue Oct 6, 2019 · 3 comments
Assignees
Labels
*as-designed Described behavior is as designed markdown Markdown support issues

Comments

@alexbarten
Copy link

  • VSCode Version: 1.39.0-insider and 1.38.1-stable
  • The insider version has no extensions installed
  • OS Version: Windows 10 Pro 1903
  • Does this issue occur when all extensions are disabled?: Yes

Markdown image links with relative paths that navigate up (..\) are not displayed in the Markdown Preview. When I press the control key + left click the link, then the image is displayed correctly in a VSCode tab. So VSCode is able to find and display the image, just not in the previewer.

I have seen quite some bug reports on this issue in the past. It is still not resolved (although the reports were closed). This puzzles me, and made me reluctant to open yet another issue, but it is too important for me to let go.

Steps to Reproduce:

  1. Create a new Markdown file.
  2. Create/copy an image in a different folder on the same level (adjacent) or higher in the folder hierarchy.
    For example: the .md in: C:\Users\you\learning\summaries
    and the image in C:\Users\you\learning\resources or n C:\Users\you\learning
  3. Refer to the image from the Markdown: ![this image will not be displayed](..\resources\example.png)

How did I test so far?

  1. I have tested with PNG and JPG files. No difference.
  2. I have used adjacent (= same level), child and parent folders. This is how I found out that child folders do not pose a problem, whereas parent and adjacent folders do. So when I use ..\ in the path the problem occurs, else not.
  3. I have used forward and backward slashes in the path description. No difference.
  4. I have used escaped and non-escaped forward and backward slashes in the path. No difference.

Example set up:

afbeelding

@mjbvz mjbvz self-assigned this Oct 6, 2019
@mjbvz
Copy link
Contributor

mjbvz commented Oct 6, 2019

What is the path of the folder you are opening in VS Code for this case? Does it include both the md file and the image files within it?

@mjbvz mjbvz added the markdown Markdown support issues label Oct 6, 2019
@alexbarten
Copy link
Author

alexbarten commented Oct 7, 2019

The folder I opened in VSCode is
C:\Users\myusername\OneDrive\Documenten\Alex\learning\summaries\

And if I only open the Markdown file and I do not open a folder, the behavior is the same (no image shown but it opens when I control-click the link in the Markdown source).

  • Markdown file path:
    C:\Users\myusername\OneDrive\Documenten\Alex\learning\summaries\document.md
  • Picture file path:
    C:\Users\myusername\OneDrive\Documenten\Alex\learning\resources\example.png
  • Alternative picture file path:
    C:\Users\myusername\OneDrive\Documenten\Alex\learning\example.png

Both picture locations refuse to show the picture in the previewer when applying

![the picture](../resources/example.png)
![the picture](../example.png)

@mjbvz
Copy link
Contributor

mjbvz commented Oct 19, 2019

Thanks for the additional info

For security reasons, the markdown preview will only load resources from the following places:

  • If you open a workspace/folder, you can load resources from inside those folders.

  • If you open a single md file, you can load resources that are in the same directory (or child directories) as the md file.

To work with you md files, I suggest you the folder that contains both the md files and the resources they reference

@mjbvz mjbvz closed this as completed Oct 19, 2019
@mjbvz mjbvz added the *as-designed Described behavior is as designed label Oct 19, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed markdown Markdown support issues
Projects
None yet
Development

No branches or pull requests

2 participants