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: Only open the first returned media element.

Karl Stolleyc36c561f07df
diff --git a/web/src/lightbox.ts b/web/src/lightbox.ts
index 7d3a3fc6cb7..6d89c23868d 100644
--- a/web/src/lightbox.ts
+++ b/web/src/lightbox.ts
@@ -671,7 +671,14 @@ export function initialize(): void {
return;
}
- open_image($original_media_element);
+ // Because a user could conceivably copy and paste a media reference
+ // from another message, and because we are selecting the original
+ // element above based on a data-url value that is therefore not
+ // guaranteed to be unique, we pass the first (possibly only) media
+ // element returned. The logic below for removing and adding the
+ // "selected" class ensures that the correct thumbnail will
+ // still be highlighted.
+ open_image($original_media_element.first());
if (!$(".image-list .image.selected").hasClass("lightbox_video") || !is_video) {
pan_zoom_control.reset();