Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

lightbox: Set payload.source on srcset.

Karl Stolley829212a76a52
diff --git a/web/src/lightbox.ts b/web/src/lightbox.ts
index c7bc7e733ad..cd6d9ab81f5 100644
--- a/web/src/lightbox.ts
+++ b/web/src/lightbox.ts
@@ -268,11 +268,15 @@ function display_image(payload: Payload): void {
$img.attr("src", payload.preview);
$img.attr("width", payload.original_width_px);
$img.attr("height", payload.original_height_px);
- $img.one("load", () => {
- $img.attr("src", payload.source);
- });
+ // srcset contains the reference to the original image,
+ // and will be preferred over the src image when available
+ $img.attr("srcset", `${payload.source} ${payload.original_width_px}w`);
+ $img.attr("sizes", "100vw");
} else {
- $img.attr("src", payload.source);
+ // this could be just assigned to src, but srcset is used here
+ // for consistency
+ $img.attr("srcset", `${payload.source} ${payload.original_width_px}w`);
+ $img.attr("sizes", "100vw");
}
$img_container.empty();
$img_container.append($img).show();