Kalan's Blog

Kalan 頭像照片,在淡水拍攝,淺藍背景

四零二曜日電子報上線啦!訂閱訂起來

Software Engineer / Taiwanese / Life in Fukuoka
This blog supports RSS feed (all content), you can click RSS icon or setup through third-party service. If there are special styles such as code syntax in the technical article, it is still recommended to browse to the original website for the best experience.

Current Theme light

我會把一些不成文的筆記或是最近的生活雜感放在短筆記,如果有興趣的話可以來看看唷!

Please notice that currenly most of posts are translated by AI automatically and might contain lots of confusion. I'll gradually translate the post ASAP

Automatically upload images in the Typora editor

category: Chat tag: typora

Typora - A handy markdown editor

Typora is a markdown editor that I love using. Up until now, I haven't found any editor that is more convenient than Typora. It has many useful features, including:

  • Support for tables
  • Support for LaTeX syntax, making it easy to write equations
  • Ability to directly drag and drop images to generate corresponding markdown syntax
  • Support for various HTML tags, such as iframe, video, ruby, etc.
  • Customizable themes (using CSS)
  • Built-in file and folder browsing and switching functionality
  • And many other useful features

These well-designed features make me love Typora even more. However, there is one annoyance when using it, which is uploading images. Typora only includes the path of the image in the markdown, like the following syntax:

![image alt](/Users/Kalan/my/image/path.png)

If you simply copy and paste this syntax, the image will not be displayed on the web page because users cannot access the path on your computer. You must upload the image to cloud storage or a server. It is quite troublesome to handle this manually, especially when the image is large. The thought of having to compress it before uploading adds an extra step, which interrupts the flow of writing.

I couldn't help but wonder if there is a way to upload images directly without leaving the editor. Typora itself supports powerful image dragging behavior, and it also works perfectly to copy and paste images from web pages. It is already a great user interface.

Finally, I came across this:

Typora Image Upload

I was amazed! This feature allows you to trigger actions when inserting images into the editor, such as moving them to a specific folder or uploading them. What's even better is that you can define your own command to upload images!

Typora Customized Image Upload Interface

In this upload command, I compressed the image, uploaded it to S3, and returned the image URL. The rest of the UI and interactive status are handled by Typora. This way, uploading images becomes completely painless!

The result looks like this:

Implementation

You can directly refer to the code on Github (written in Node.js). It's quite simple to implement, but I installed some packages to finish it quickly. If you prefer to start from scratch, you can try writing it yourself. Currently, it only supports uploading to S3.

Afterword

From now on, a new window has opened in my life. I will no longer procrastinate writing posts because of the hassle of dealing with photos. I share this with everyone who loves using markdown to create content.

Prev

eRemote IR Remote Control with Google Home for Smart Home

Next

What's new about working remotely for 4 months in Fukuoka

If you found this article helpful, please consider buy me a drink ☕️ It'll make my ordinary day shine✨

Buy me a coffee