Skip to content

Markdown: Drop (or paste) image, file destination: relative path #193752

Closed
@mrienstra

Description

@mrienstra

As per docs/languages/markdown#_inserting-images-and-links-to-files:

By default VS Code automatically copies dropped or pasted images outside of the workspace into your workspace. The markdown.copyFiles.destination setting controls where the new image file should be created.

It would be useful to add two more variables containing the relative path.

Using the same example file as the docs (/docs/api/readme.md), and the same glob pattern ("/docs/**/*"):

  1. Relative to the workspace, e.g. /docs/api/. This would be the same path that is returned by the "Copy Relative Path" command (copyRelativePathCommandHandler), minus the filename. I'll tentatively call this documentRelativeDirName.
  2. Relative to the glob path, in this case, given a glob pattern of "/docs/**/*", the path relative to /docs/ would be /api/. I'll tentatively call this documentGlobRelativeDirName.

These would be useful if a project wishes to place all images within, say, /src/assets/.

Using (1) above, an image dragged or pasted into /docs/api/readme.md would be copied into /src/assets/docs/api/readme/ (for the destination "/src/assets/${documentRelativeDirName}/"), and using (2), into /src/assets/api/readme/ (for the destination "/src/assets/${documentGlobRelativeDirName}/").

(the names documentRelativeDirName & documentGlobRelativeDirName are not intended to be thoughtful suggestions, just throwing them out as examples to facilitate discussion)

As this comment points out, documentDirName provides the absolute file system path, rather than the workspace-relative path as some might expect.

References:

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalitymarkdownMarkdown support issuesverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions