mushanshitiancai / vscode-paste-image

paste image from clipboard to markdown/asciidoc directly!
MIT License
423 stars 128 forks source link

Specify image folder relative to file location? #32

Closed gandalfsaxe closed 5 years ago

gandalfsaxe commented 5 years ago

Hi,

I can't quite figure out how to put all images into a subdirectory assets/ at the location of the current markdown file. All the examples seems to refer to the project root. I tried this:

"pasteImage.basePath": "${currentFileDir}/assets/"

But it still puts the images in the same folder as the markdown file and the path of all the images gets prepended with ../, such that:

![](2018-10-19-10-43-32.png)

becomes

![](../2018-10-19-10-43-32.png)

So the setting above actually just breaks the image insertions (since the file is still in same folder as the md file) instead of doing what I want. Any suggestions?

thundernixon commented 5 years ago

I got this working the other day by adding the following to my VS Code settings.json:

    "pasteImage.path": "${currentFileDir}/assets",
    "pasteImage.basePath": "${currentFileDir}",
    "pasteImage.forceUnixStyleSeparator": true,
    "pasteImage.

It worked great for a bit ... but then stopped working. :/ So, give it a try, but I'm not sure if I also messed it up, or if something maybe changed in the extension / my computer that made it not work.

mushanshitiancai commented 5 years ago

@GandalfSaxe Hi, pasteImage.path is the path that image will save in. For example:

  1. artile path: /user/mushan/blog/a.md
  2. pasteImage.path=${currentFileDir}/assets
  3. paste, image will be saved in /user/mushan/blog/asserts, and will insert in article

@thundernixon Thank you, you suggestion is right.

gandalfsaxe commented 5 years ago

Ah that works, excellent 👍 I was using pasteImage.Basepath instead of pasteImage.path.

thundernixon commented 5 years ago

Ohh it took me awhile to find my error, but if anyone else is struggling:

  1. All I needed in the VS Code user settings JSON was "pasteImage.path": "${currentFileDir}/assets", (not the other lines)
  2. I needed to use Option Command V to paste the image, and I was forgetting the Option key