Preface
I have written an article about using Docker to build a personal image hosting service based on Chevereto. However, if you use the most basic method mentioned in the article, that is, directly upload the image using the Chevereto web page and then get the URL from the image properties, it will be very inefficient and most people will not do this. The normal way is: you directly use a common editor to write an article. When you need to insert an image at a certain location, you can directly use the screenshot tool to take a screenshot, and then paste the image directly in the editor. The image will be automatically uploaded to the image hosting service and a corresponding image link will be generated at that location.
To achieve this effect, three prerequisites are required: a ready-made image hosting service (chevereto in this article), PicGo installed locally, and the markdown editor commonly used for writing articles supports automatic clipboard uploading and uploader function settings.
Setting up chevereto
chevereto里的设置不多,主要是修改route.api.php中的”$uploaded_id”参数(具体在创建chevereto容器的时候如何提前挂载route.api.php文件的相关操作见我另一篇文章:Docker series uses Docker to build your own image bed based on Chevereto)):
The code is as follows:
$uploaded_id = CHV\Image::uploadToWebsite($source, 'test', array('album_id'=>3));
The main thing is to modify the username (test above) and the album id (3 above): the username is the username you use to log in to chevereto, and I have also introduced in detail how to obtain the album id in the article mentioned above.
The reason for modifying uploaded_id is that by default, when PicGo uploads pictures through the chevereto API, it will only be uploaded to the guest album, and we definitely want to upload it to a specific album under a certain user name, so we need to modify it as needed.
然后就是API密钥的获取,在”Dashboard”-“Settings”-“API”路径下,如下面几张图:
The red box is the API key:
Setting up PicGo
First, install the corresponding PicGo APP according to your desktop operating system. I installed the Mac version. Search for chevereto in the plug-in settings in the main interface. I installed chevereto 1.1.0 in the red box:
在图床设置下红框中的”Chevereto Uploader”的Url和Key分别填写你的个人图床信息,Key就是上一节最后的API key,url的格式如下:
https://example.com/api/1/upload # For the address part, fill in the public domain name or IP address of your chevereto image hosting service. If there is a port, add it after the domain name using the format of :port
As shown below:
Finally, make the following configurations in the red box in PicGo settings, and set other options according to your needs:
This completes the PicGO setup.
Obsidian Settings
Obsidian里设置也简单,首先在第三方插件里进行安装红框中的”Image auto upload Plugin”:
Then perform the following configuration in the red box in the plug-in you just installed:
Summarize
After the above simple settings, you only need to take a screenshot and paste it when writing an article in Obsidian, and you can generate a picture link at the specified location. For example, this article is written in Obsidian, and the picture effect is as follows: