FIX: respect img size when quoting multiple elements (#35144)

Adds the width/height to quoted images when selecting and quoting
multiple elements from a post at once.
This commit is contained in:
David Battersby
2025-10-03 09:10:00 +04:00
committed by GitHub
parent 3c8d6504be
commit 16518f6d33
2 changed files with 12 additions and 2 deletions
@@ -365,6 +365,16 @@ export class Tag {
href = `upload://${base62SHA1}`;
}
const width = img.attributes.width;
const height = img.attributes.height;
if (width && height) {
const pipe = this.element.parentNames.includes("table")
? "\\|"
: "|";
text = `${text}${pipe}${width}x${height}`;
}
return `![${text}](${href})`;
}
@@ -424,7 +424,7 @@ helloWorld();</code>consectetur.`;
<span class="filename">sherlock3_sig.jpg</span><span class="informations">5496×3664 2 MB</span><span class="expand"></span>
</div></a>
`;
let markdown = `![sherlock3_sig.jpg](https://d11a6trkgmumsb.cloudfront.net/uploads/default/original/1X/8hkjhk7692f6afed3cb99d43ab2abd4e30aa8cba.jpeg)`;
let markdown = `![sherlock3_sig.jpg|689x459](https://d11a6trkgmumsb.cloudfront.net/uploads/default/original/1X/8hkjhk7692f6afed3cb99d43ab2abd4e30aa8cba.jpeg)`;
assert.strictEqual(toMarkdown(html), markdown);
@@ -437,7 +437,7 @@ helloWorld();</code>consectetur.`;
<span class="filename">sherlock3_sig.jpg</span><span class="informations">5496×3664 2 MB</span><span class="expand"></span>
</div></a>
`;
markdown = `![sherlock3_sig.jpg](upload://1frsimI7TOtFJyD2LLyKSHM8JWe)`;
markdown = `![sherlock3_sig.jpg|689x459](upload://1frsimI7TOtFJyD2LLyKSHM8JWe)`;
assert.strictEqual(toMarkdown(html), markdown);
});