mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
postprocess: Fix animated images automatically playing on Firefox.
This commit fixes a bug where animated images automatically play on Firefox because the image source didn't output the same URL across different browsers. Currently, the image source is normalized to ensure consistent URLs across different browsers. Fixes #33248 Co-authored-by: Alex Vandiver <alexmv@zulip.com>
This commit is contained in:
@@ -108,7 +108,15 @@ export function postprocess_content(html: string): string {
|
||||
"div.message_inline_image > a > img",
|
||||
)) {
|
||||
inline_img.setAttribute("loading", "lazy");
|
||||
if (inline_img.src.startsWith("/user_uploads/thumbnail/")) {
|
||||
// We can't just check whether `inline_image.src` starts with
|
||||
// `/user_uploads/thumbnail`, even though that's what the
|
||||
// server writes in the markup, because Firefox will have
|
||||
// already prepended the origin to the source of an image.
|
||||
const image_url = new URL(inline_img.src, window.location.origin);
|
||||
if (
|
||||
image_url.origin === window.location.origin &&
|
||||
image_url.pathname.startsWith("/user_uploads/thumbnail/")
|
||||
) {
|
||||
let thumbnail_name = thumbnail.preferred_format.name;
|
||||
if (inline_img.dataset.animated === "true") {
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user