amtoaer

晓风残月

叹息似的渺茫,你仍要保存着那真!
github
x
telegram
steam
nintendo switch
email

Integrate sm.ms image hosting into Typora for a smooth experience.

The reason for this is that a classmate recommended using typora to write markdown. The official website was slow for him, so I helped him download it and took a look around. Only then did I realize that typora has so many customization options! (Yes, I have been using the default settings for over a year XD)

Taking this as an opportunity, I opened its preference settings for the first time and checked out the various options. I found a very interesting feature: "Automatically Upload Inserted Images". I thought it was quite convenient, so I decided to configure it...

Note: I am using linux, so windows users should refer to this with discretion (installation methods and configuration file paths may vary slightly)

Installation#

In typora, there are optional upload configurations such as Picgo, Picgo-core, custom command, and none. I used Picgo a long time ago, but its UI built with electron was not a good experience on linux, so this time I chose the command-line version of Picgo-core.

First, install it:

npm install picgo -g
# or
yarn global add picgo

Plugin Configuration#

Note: windows users, please make sure to add picgo to the environment variables. Otherwise, you need to replace all instances of picgo in the following text with path+picgo (e.g., C:\picgo\picgo.exe).

Picgo itself supports multiple image hosting services. I chose the convenient and free SM.MS. On the project homepage, we learned that:

PicGo supports the following image hosting services:

  • SM.MS v1.5.1 Since the official no longer supports the V1 version, please temporarily use the smms-user plugin

This means that we need to install an additional plugin to use the SM.MS image hosting service. So, open the terminal and execute:

picgo install smms-user

After the installation is successful, we still need to configure it. Execute the following command:

picgo config plugin smms-user
? Auth 

You need to enter your TOKEN here. First, register an account on the SM.MS website, then visit this link to obtain your TOKEN and enter it. You should receive the following prompt:

[PicGo SUCCESS]: Configure config successfully!

Next is the final step. You need to change the uploader you are using to smms-user. In the command line, execute:

picgo config uploader
? Choose a(n) uploader (Use arrow keys)
 smms-user 
  smms 
  tcyun 
  github 
  qiniu 
  imgur 
  aliyun 
(Move up and down to reveal more choices)

Move the arrow and select smms-user, then press Enter. At this point, the content of your ~/.picgo/config.json configuration file should look like this:

{
  "picBed": {
    "current": "smms-user",
    "uploader": "smms-user",
    "transformer": "path",
    "smms-user": {
      "Authorization": "your token"
    }
  },
  "picgoPlugins": {
    "picgo-plugin-smms-user": true
  },
  "picgo-plugin-smms-user": {
    "Authorization": "your token"
  }
}

The configuration for the image upload service is complete!

Integration with Typora#

After configuring the upload service, you can now integrate it with typora.

Open the Typora preference settings and select custom command in the upload service settings (here's an explanation: selecting Picgo-core will only allow you to use the specified path, but we still need to use custom command to specify our own path). Then, enter the following in the text box below:

picgo upload

Integration is complete! You can now try clicking the "Validate Image Upload Options" button next to it to test if the upload was successful.

Tips#

Currently, only dragging files into typora supports uploading. If you directly paste from the clipboard, typora will automatically place the image in the ~/upload folder but will not upload it automatically. You need to manually click "Upload Image". This is a bug in typora itself:

This should be a bug, there's no need to create the "upload" folder.

Refer to #3331 for more details.

References#

  1. Picgo
  2. Picgo-core
  3. picgo-plugin-smms-user
  4. Picgo-core document
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.