From f7ec566ae55fa04ab4cb5a5c6adcaae1aadc3a69 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Sun, 29 Jun 2025 14:58:29 +0800 Subject: [PATCH] fix(plugin-md-power): catch `image-size` error (#634) --- plugins/plugin-md-power/src/node/enhance/imageSize.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/plugin-md-power/src/node/enhance/imageSize.ts b/plugins/plugin-md-power/src/node/enhance/imageSize.ts index 5a942203..1408855c 100644 --- a/plugins/plugin-md-power/src/node/enhance/imageSize.ts +++ b/plugins/plugin-md-power/src/node/enhance/imageSize.ts @@ -255,8 +255,11 @@ export async function resolveImageSize(app: App, url: string, remote = false): P if (url[0] === '/') { const filepath = app.dir.public(url.slice(1)) if (fs.existsSync(filepath)) { - const { width, height } = imageSize(fs.readFileSync(filepath)) - return { width: width!, height: height! } + try { + const { width, height } = imageSize(fs.readFileSync(filepath)) + return { width: width!, height: height! } + } + catch {} } }