diff --git a/src/config.ts b/src/config.ts index 76fe3d1..ba2a326 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,5 @@ export const ATTACHMENT_URL_REGEXP = - /!\[\[((.*?)\.(\w+))(?:\s*\|\s*(?\d+)\s*(?:[*|x]\s*(?\d+))?)?\]\]/g; + /!\[\[((.*?)\.(\w+))(?:\s*\|\s*(?\d+%?)\s*(?:[*|x]\s*(?\d+%?))?)?\]\]/g; export const MARKDOWN_ATTACHMENT_URL_REGEXP = /!\[(.*?)\]\(((.*?)\.(\w+))\)/g; diff --git a/src/utils.ts b/src/utils.ts index f6b83ec..a8d958f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -771,13 +771,18 @@ export async function tryCopyMarkdownByRead( if (plugin.settings.displayImageAsHtml) { const { width = null, height = null } = imageLinks[index]?.groups || {}; + // Helper to format size value - append 'px' only if not a percentage + const formatSize = (value: string | null) => { + if (!value) return ""; + return value.includes("%") ? value : `${value}px`; + }; const style = width && height - ? ` style='width: {${width}}px; height: ${height}px;'` + ? ` style='width: ${formatSize(width)}; height: ${formatSize(height)};'` : width - ? ` style='width: ${width}px;'` + ? ` style='width: ${formatSize(width)};'` : height - ? ` style='height: ${height}px;'` + ? ` style='height: ${formatSize(height)};'` : ""; content = content.replace(