Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const ATTACHMENT_URL_REGEXP =
/!\[\[((.*?)\.(\w+))(?:\s*\|\s*(?<width>\d+)\s*(?:[*|x]\s*(?<height>\d+))?)?\]\]/g;
/!\[\[((.*?)\.(\w+))(?:\s*\|\s*(?<width>\d+%?)\s*(?:[*|x]\s*(?<height>\d+%?))?)?\]\]/g;

export const MARKDOWN_ATTACHMENT_URL_REGEXP = /!\[(.*?)\]\(((.*?)\.(\w+))\)/g;

Expand Down
11 changes: 8 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down