Skip to content

Commit 4c50866

Browse files
authored
Update gallery expandos (#5570)
Each item in a gallery now refers to the item itself, not the entire gallery. Clicking e.g. an image will open the image in a new window instead of opening the gallery.
1 parent e9a51b0 commit 4c50866

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/modules/showImages.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ function generateMedia(options: ExpandoMedia, context: {| href: string |}): Medi
11371137
if (options.caption) options.caption = DOMPurify.sanitize(options.caption);
11381138
11391139
switch (options.type) {
1140-
case 'GALLERY': return new Gallery(options, context);
1140+
case 'GALLERY': return new Gallery(options);
11411141
case 'IMAGE': return new Image(options, context);
11421142
case 'TEXT': return new Text(options);
11431143
case 'IFRAME': return new Iframe(options);
@@ -1399,7 +1399,7 @@ class Gallery extends Media {
13991399
rememberResizeWidth: boolean;
14001400
lastResizedWidth: number;
14011401
1402-
constructor(options: GalleryMedia, context) {
1402+
constructor(options: GalleryMedia) {
14031403
super();
14041404
14051405
this.element = galleryTemplate({
@@ -1418,7 +1418,8 @@ class Gallery extends Media {
14181418
this.ctrlConcurrentIncrease = this.element.querySelector('.res-gallery-increase-concurrent');
14191419
14201420
this.pieces = options.src.map(src => ({
1421-
generateMedia: () => generateMedia(src, context),
1421+
// Use the piece's source, not the gallery's URL, as the context
1422+
generateMedia: () => generateMedia(src, { href: src.src }),
14221423
media: null,
14231424
wrapper: string.html`<div hidden></div>`,
14241425
}));

0 commit comments

Comments
 (0)