perf(plugin-md-power): improve image-size

This commit is contained in:
pengzhanbo 2025-07-26 09:09:52 +08:00
parent 9f1948cf05
commit 0443c6ff05

View File

@ -119,11 +119,16 @@ export async function imageSizePlugin(
if (!fs.existsSync(filepath))
return false
const { width: w, height: h } = imageSize(fs.readFileSync(filepath))
if (!w || !h)
return false
try {
const { width: w, height: h } = imageSize(fs.readFileSync(filepath))
if (!w || !h)
return false
cache.set(filepath, { width: w, height: h })
cache.set(filepath, { width: w, height: h })
}
catch {
return false
}
}
}