mushanshitiancai / vscode-paste-image

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

Add an option to set up alt text #98

Closed natakazakova closed 2 years ago

natakazakova commented 3 years ago

Hi. I need a capability to specify alt text for the image.

 ![alt text](image URL)

Alt text helps people with visual impairments understand pictures and other graphical content when they use a screen reader. And Google recommends to use annotations for images and video.

As I found in the extension settings, I can configure only the image URL part. I use the human-readable image names and what I need is a template to insert the image name to alt text: ![human-readable-image-name](some-path/human-readable-image-name.png). Is it possible?

Chaphasilor commented 2 years ago

It works if you set pasteImage.insertPattern to ![${imageFileNameWithoutExt}](${imageFilePath}${imageSyntaxSuffix}!
It's a bit of a workaround, and you need to first type the alt text, then select it, and then paste the image...

Keep in mind that the image name will be the escaped alt text.

Here's a quick demo:
https://user-images.githubusercontent.com/18015147/138860998-b5aa791d-7c16-45de-b97e-7599c7c1c841.mp4

natakazakova commented 2 years ago

@Chaphasilor wow, great! This is exactly what I need. Thanks a lot. This workaround works great.