picgo-plugin-web-uploader icon indicating copy to clipboard operation
picgo-plugin-web-uploader copied to clipboard

如何添加自定义域名前缀的选项?

Open lshcool opened this issue 11 months ago • 2 comments

如何添加自定义域名前缀的选项? 并且在相册正常显示自定义域名前缀。 Snipaste_2024-03-17_22-27-05 如图所示,即便上传成功,但相册链接,没有 https://自定义域名 图片不显示。 小白提问,望有回复,谢谢。

lshcool avatar Mar 17 '24 14:03 lshcool

我也遇到整个问题了。我就fork了下作者的仓库,简单改了下能够支持前缀的选项了。我把它发布到npm上去了 你可以搜索这个插件 picgo-plugin-web-uploader-byzh

hengtop avatar May 18 '24 16:05 hengtop

同样遇到这个问题,做了一个插件(picgo-plugin-web-uploader-re)用于更复杂的正则替换:

新增了两个配置项 matchPattern 和 replacePattern,用于接收正则表达式的匹配模式和替换模式。在处理函数中,对解析出的 imgUrl 进行正则替换:imgUrl.replace(new RegExp(matchPattern, 'g'), replacePattern)

示例1:将 /images/uploaded/pic.jpg 替换为 https://cdn.example.com/pic.jpg:

  • matchPattern: "^/images/uploaded",
  • replacePattern: "https://cdn.example.com"

示例2:将任意文件路径 pic.jpg、images/test.png 等替换为带前缀的 URL,例如 https://cdn.example.com/pic.jpg、https://cdn.example.com/images/test.png:

  • matchPattern: ".*",
  • replacePattern: "https://cdn.example.com/$&"

sunieee avatar May 31 '24 09:05 sunieee