fix(plugin-md-power): catch image-size error (#634)

This commit is contained in:
pengzhanbo 2025-06-29 14:58:29 +08:00 committed by GitHub
parent 309be687b4
commit f7ec566ae5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -255,8 +255,11 @@ export async function resolveImageSize(app: App, url: string, remote = false): P
if (url[0] === '/') { if (url[0] === '/') {
const filepath = app.dir.public(url.slice(1)) const filepath = app.dir.public(url.slice(1))
if (fs.existsSync(filepath)) { if (fs.existsSync(filepath)) {
const { width, height } = imageSize(fs.readFileSync(filepath)) try {
return { width: width!, height: height! } const { width, height } = imageSize(fs.readFileSync(filepath))
return { width: width!, height: height! }
}
catch {}
} }
} }