mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
图床压缩
This commit is contained in:
@@ -7,11 +7,14 @@ import BLOG from '@/blog.config'
|
||||
* @param {*} image
|
||||
*/
|
||||
const compressImage = (image, width = 400) => {
|
||||
if (image && image.indexOf(BLOG.NOTION_HOST) === 0) {
|
||||
if (!image) {
|
||||
return null
|
||||
}
|
||||
if (image.indexOf(BLOG.NOTION_HOST) === 0) {
|
||||
return `${image}&width=${width}`
|
||||
}
|
||||
// 压缩unsplash图片
|
||||
if (image && image.indexOf('https://images.unsplash.com/') === 0) {
|
||||
if (image.indexOf('https://images.unsplash.com/') === 0) {
|
||||
// 将URL解析为一个对象
|
||||
const urlObj = new URL(image)
|
||||
// 获取URL参数
|
||||
@@ -27,6 +30,12 @@ const compressImage = (image, width = 400) => {
|
||||
return urlObj.toString()
|
||||
}
|
||||
|
||||
// 此处还可以添加您的自定义图传的封面图压缩参数。
|
||||
// .e.g
|
||||
if (image.indexOf('https://your_picture_bed') === 0) {
|
||||
return 'do_somethin_here'
|
||||
}
|
||||
|
||||
return image
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user