mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
postprocess: Process YouTube images in image loop.
This commit is contained in:
@@ -98,18 +98,6 @@ export function postprocess_content(html: string): string {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update older, smaller default.jpg YouTube preview images
|
|
||||||
// with higher-quality preview images (320px wide)
|
|
||||||
if (elt.parentElement?.classList.contains("youtube-video")) {
|
|
||||||
const img = elt.querySelector("img");
|
|
||||||
assert(img instanceof HTMLImageElement);
|
|
||||||
const img_src = img.src;
|
|
||||||
if (img_src.endsWith("/default.jpg")) {
|
|
||||||
const mq_src = img_src.replace(/\/default.jpg$/, "/mqdefault.jpg");
|
|
||||||
img.src = mq_src;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a class to the anchor tag on
|
// Add a class to the anchor tag on
|
||||||
if (elt.parentElement?.classList.contains("message_embed_title")) {
|
if (elt.parentElement?.classList.contains("message_embed_title")) {
|
||||||
elt.classList.add("message-embed-title-link");
|
elt.classList.add("message-embed-title-link");
|
||||||
@@ -134,6 +122,17 @@ export function postprocess_content(html: string): string {
|
|||||||
message_media_link?.removeAttribute("title");
|
message_media_link?.removeAttribute("title");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update older, smaller default.jpg YouTube preview images
|
||||||
|
// with higher-quality preview images (320px wide)
|
||||||
|
if (message_media_wrapper.classList.contains("youtube-video")) {
|
||||||
|
assert(message_media_image instanceof HTMLImageElement);
|
||||||
|
const img_src = message_media_image.src;
|
||||||
|
if (img_src.endsWith("/default.jpg")) {
|
||||||
|
const mq_src = img_src.replace(/\/default.jpg$/, "/mqdefault.jpg");
|
||||||
|
message_media_image.src = mq_src;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Replace the legacy .message_inline_image class, whose
|
// Replace the legacy .message_inline_image class, whose
|
||||||
// name would add confusion when Zulip supports inline
|
// name would add confusion when Zulip supports inline
|
||||||
// images via standard Markdown, with dedicated classes
|
// images via standard Markdown, with dedicated classes
|
||||||
|
|||||||
Reference in New Issue
Block a user