Template talk:Gallery/Archive 2

Add a parameter to remove the white background
I implemented a parameter to remove the white background, and using original grey background instead, the new source code is available at the sandbox pages of this template, and you can go to the test cases to see the effects. -- Great Brightstar (talk) 12:43, 9 May 2020 (UTC)
 * The test cases look okay to me. Was there any particular reason this new parameter is needed? &mdash; Martin (MSGJ · talk) 12:35, 11 May 2020 (UTC)
 * OK, I see an article Fleur-de-lis use this template to display the flags and arms at one section, all of them are bordered even if there is one flag has non-quadrilateral design, however the border can be cancelled, but the white background cannot be cancelled, so I made this new parameter. -- Great Brightstar (talk) 03:35, 12 May 2020 (UTC)
 * With this support it's possible to fix a gallery that can be present with neither white background nor gray border. -- Great Brightstar (talk) 03:40, 14 May 2020 (UTC)
 * Great Brightstar, can you explain the changes you are requesting [//en.wikipedia.org/w/index.php?title=Special%3AComparePages&page1=Module%3AGallery&page2=Module%3AGallery%2Fsandbox here]? I understand that most of it is due to one using the sandbox class and other other using the main classes, but I am concerned about the very end of the diff.  for some reason, you are adding doing a no-op when yes, and adding the class whitebg when the whitebg is undefined.  I would expect the reverse.  if your intention is to enable no then you need to use Module:Yesno. Frietjes (talk) 14:59, 14 May 2020 (UTC)
 * Thanks for your digging up, I got better solution for this parameter. By default, the white background always on, if you use no you'll turn it off. --Great Brightstar (talk) 16:51, 14 May 2020 (UTC)
 * Great Brightstar, okay, now implemented but with Module:Yesno which should be more robust. Frietjes (talk) 22:22, 14 May 2020 (UTC)

Fix for mobile view
Normally the width of gallery always follows the width of device screen if you see it on your phone. But if this template has only one gallery box containing imege, the width of template is smaller, thus cause inconsistency on some articles such as Flag of Bosnia and Herzegovina and Flag of Spain, so I made a fix to the TemplateStyles, and added a test case for this. Many major desktop browsers has ability to enable the mobile view from their dev tools, so you'll be able to access the mobile view on your computer and see the effect. -- Great Brightstar (talk) 09:00, 18 May 2020 (UTC)
 * I don't see the point of using a gallery for a single image. Just use the normal image syntax, making sure that thumb is used. -- Red rose64 &#x1f339; (talk) 09:11, 18 May 2020 (UTC)
 * See here: Template:Gallery/testcases--Great Brightstar (talk) 09:17, 18 May 2020 (UTC)
 * So use . -- Red rose64 &#x1f339; (talk) 09:33, 18 May 2020 (UTC)


 * OK, I did. Great Brightstar (talk) 10:11, 18 May 2020 (UTC)
 * You can also see the effect here, since I ported the source to the commons. -- Great Brightstar (talk) 10:45, 18 May 2020 (UTC)
 * Red question icon with gradient background.svg Not done: it's not clear what changes you want to be made. Please mention the specific changes in a "change X to Y" format and provide a reliable source if appropriate. Primefac (talk) 15:02, 19 May 2020 (UTC)
 * OK, let me explain. The tag usually set the container as 100% on mobile view to make sure the image always centered in the box, but this template lakes the support, so I added a rule as a   query in the TemplateStyles to produce the same effect in the container, and make it align with the MediaWiki's native output. BTW I made a small change to make the bordered-images class more distinguishable. --Great Brightstar (talk) 02:11, 20 May 2020 (UTC)
 * Here I show you some screenshots to see what's wrong with this template:
 * https://postimg.cc/nsfYyGYG
 * https://postimg.cc/yWph1Hyd
 * https://postimg.cc/QVdkZt5w
 * --Great Brightstar (talk) 02:25, 20 May 2020 (UTC)
 * Alternatively, you can open this page with an online tester to see the effects. --Great Brightstar (talk) 06:47, 24 May 2020 (UTC)
 * I can't see any differences between sandbox and live on the devices shown on codebeautify &mdash; Martin (MSGJ · talk) 21:30, 24 May 2020 (UTC)
 * MSGJ: I can see the effect. There is a small iPhone simulator on this tester, which placed between iPad and MacBook, when I open the page at the tester, scroll on the iPhone simultor, it happens to me. --Great Brightstar (talk) 04:30, 26 May 2020 (UTC)
 * Okay yes I can see a difference. I still don't really understand this request, but it seems there is no downside. I am happy to implement if no one else has concerns &mdash; Martin (MSGJ · talk) 20:16, 26 May 2020 (UTC)
 * Where does the 720px come from? What is the reason for this value? &mdash; Martin (MSGJ · talk) 06:32, 27 May 2020 (UTC)
 * This is following a policy made by MediaWiki developer, which set 720px as a breakpoint to represent tablet device, which is documented at mw:Help:TemplateStyles, and there are several templates were already adopted that, including stack, Multiple image and Graph:Chart, so do I. --Great Brightstar (talk) 14:29, 27 May 2020 (UTC)
 * Okay I've deployed. Please check that is working as intended. &mdash; Martin (MSGJ · talk) 09:52, 28 May 2020 (UTC)

Handling of URLs containing '?'
I encountered a rendering problem caused by the use of external URLs containing '?' that occur in the description text of a gallery entry. I have documented the problem on the following page: Gallery glitch. Thanks for taking a look! SteveChervitzTrutane (talk) 22:03, 8 June 2020 (UTC)
 * SteveChervitzTrutane, the problem is the = in the URL, not the ?. this is a problem with all templates that use implicit number parameters (for example, see here for example). you can fix the problem by any of the following methods (a) change the = to =, (b) use https://www.youtube.com/watch?v=56gzV0od6DU , (c) use  , (d) explicitly number the parameters passed to gallery (not recommended).  luckily, these errors are tracked in a tracking category for repair. Frietjes (talk) 17:45, 9 June 2020 (UTC)
 * Thanks for the tips Frietjes. I went with option b. I thought there is probably an issue tracker for these sort of reports, but figured posting on the talk page would be quicker ;) I now see the Phabricator and will familiarize myself with it for future reference. SteveChervitzTrutane (talk) 07:07, 17 June 2020 (UTC)
 * SteveChervitzTrutane, you will see that your sandbox is in Category:Pages using gallery with unknown parameters which is where we track pages using incorrect syntax for gnomes to fix. Frietjes (talk) 14:35, 17 June 2020 (UTC)

Is it necessary to set captions in white?
I feel something weird while I see the test cases. The captions are always in white background if  is enabled, even if the template is set another background color for the whole area. However it doesn't happened in Multiple image, which doesn't has specific parameter do that. So what do you think of? If you think something wrong in the main template, you can apply my fixes from sandbox. -- Great Brightstar (talk) 04:21, 24 June 2020 (UTC)

Migrating to gallery tag
As far as I understand, most pages using this Gallery template do not specify any specific advanced option, and can be replaced by the normal gallery tag. I propose to migrate these to the gallery tag for simplicity. Let me know what you think. --Ita140188 (talk) 05:39, 24 June 2020 (UTC)

Numeric index option?
Found a strange option in the template that does not seem to be documented at Template:Gallery nor can I find it documented in historic edits of the Template documentation. It pertains to the numbering of each gallery item (image or text). The numbering then determines the order of where each gallery item is displayed. I noticed it when attempting to edit an article (Flags of the U.S. states and territories) and encountered this:

😲 It made editing this a bit of a challenge as if one wants to insert a gallery item, one must renumber all the previous or subsequent items. I decided for myself, and for future editors, to just redo the entire section to look the same as other Gallery Templates I've seen.

I'm curious though, is this a known "feature"? Legacy option in code? Thanks.– ░▒▓ №∶72.234.220.38 (talk) 02:05, 1 July 2020 (UTC) ▓▒░
 * Any template that accepts positional (unnamed) parameters will permit those parameters to be explicitly numbered. -- Red rose64 &#x1f339; (talk) 17:16, 1 July 2020 (UTC)
 * Ah, thank you for the explanation Red rose64 &#x1f339;, I had no idea about this numbered parameter option. Never saw it used or documented, I guess someone early on must have known & used it on that article. BTW, I think you may have assisted me at some time in the past, could have been a decade or more ago. I recall your  colour ful name. My IP address was smaller back then. 😉  Thanks again.– ░▒▓ №∶72.234.220.38 (talk) 11:59, 2 July 2020 (UTC) ▓▒░

Left margin for header and footer
In Lua module I made a small implementation to add the left margin for the title and footnote, just make use of the native style. The test cases shows this is good for text alignment with following gallery box on mobile view, rather than shift to left. -- Great Brightstar (talk) 03:58, 10 September 2020 (UTC)
 * There seem to be other changes in the sandbox, e.g. .mod-gallery .caption. Are these related to this request? &mdash; Martin (MSGJ · talk) 08:20, 17 September 2020 (UTC)


 * OK, let me explain. First, for, that's actually not related to the request, but is due to my discovery after my change. I haven't seen any element used   class in the module, making it useless, so I dropped it from TemplateStyles page. Second, I also discovered the module page have set   for the main content, so I transferred that to the TemplateStyles, and the test cases shows it works as expected in the contents, though it's not related to this change, if you think that is useful, you can apply into main template. Third, the   is related to this change, after I made the change in the module page, I found that could cause the footer text was truncated on mobile view, so I add additional rule to fix, that is part of this request. Regards. --Great Brightstar (talk) 09:20, 18 September 2020 (UTC)
 * Okay I have made the changes. Please check they are working as intended. &mdash; Martin (MSGJ · talk) 11:43, 18 September 2020 (UTC)


 * I viewed the change, but I found a small problem in the module. The second hyphen is lost for the function related to the align parameter, can add it back? Thanks.


 * -- Great Brightstar (talk) 12:14, 18 September 2020 (UTC)
 * Yes check.svg Done &mdash; Martin (MSGJ · talk) 20:05, 18 September 2020 (UTC)

Locator map in gallery: is it possible?
I have been trying to add the collapsible version of the template to the locator-map at Belgian Army order of battle (1914) but have not had any success. Is it possible to use the two together? Any help much appreciated! —Brigade Piron (talk) 10:57, 19 September 2020 (UTC)


 * This template is unable to accept locator maps, but you can try to make use of Hidden begin, Hidden end and Gallery items to produce such galleries. --Great Brightstar (talk) 08:15, 26 September 2020 (UTC)

Gallery on Kernowek (kw-wiki)
I've copied most of the relevant templates and modules onto the Cornish WP, but there's at least one missing! Any help would be greatly appreciated! Llywelyn2000 (talk) 12:30, 15 November 2020 (UTC)


 * Hi. In this case it's because your closing tag is ). However, note that the gallery tag is not handled by the copied templates/modules afaik, that's handled by the software. For this template, you would have to use template syntax. I've made an edit to the sandbox you linked to demonstrate (see source). Hope that helps. ProcrastinatingReader (talk) 18:24, 15 November 2020 (UTC)
 * Bore da! Good morning! I didn't spot the missing forward slash as I was looking elsewhere! It is at times like this one feels just like an absolute plonker! Many thanks! Llywelyn2000 (talk) 08:19, 16 November 2020 (UTC)

Modification for the top margin
After my investigation with Firefox's dev tools, I have a suggestion for the  class, the   property should be modified using em unit, like this: -- Great Brightstar (talk) 18:42, 30 October 2020 (UTC)
 * ✅ anyone should revert if unforeseen breakage occurs. — xaosflux  Talk 16:42, 18 November 2020 (UTC)

Proposal for using outline property to images
This template currently using border property to add a grey border to images until noborder is used, however this border is actually take extra height and width, making the image shifted in 1px on screen. To get better alignment, I suggest to use outline property within bordered-images class to add a grey border for images. -- Great Brightstar (talk) 10:33, 1 January 2021 (UTC)
 * Red question icon with gradient background.svg Not done: it's not clear what changes you want to be made. Please mention the specific changes in a "change X to Y" format and provide a reliable source if appropriate. —&thinsp;JJMC89&thinsp; (T·C) 20:11, 2 January 2021 (UTC)
 * So let's see my fix: --Great Brightstar (talk) 20:44, 2 January 2021 (UTC)
 * Red information icon with gradient background.svg Not done for now: I don't see a need to worry/bother about the extra width/height. What is the actual problem with the current styling? Izno (talk) 18:50, 22 January 2021 (UTC)

Preview warning and hatnotes moving to templatestyles
Page watchers may be interested in Izno (talk) 00:22, 29 April 2021 (UTC)

Faulty "packed" mode?
Does work for anyone else? The documentation states that either "width" or "height" can be used, but in my experience only "height" seems to have any effect.

Perhaps something somewhere is faulty? – Scyrme (talk) 22:26, 5 April 2023 (UTC)


 * I'm seeing what you describe, but width is working if packed mode is turned off. small jars 17:23, 6 April 2023 (UTC)
 * You're right. It appears width does work with default or nolines modes. Perhaps the problem is with packed mode or how the two interact then? The height parameter works exactly as expected, regardless of whether an image is in portrait or landscape orientation. – Scyrme (talk) 17:55, 6 April 2023 (UTC)
 * It also seems that doesn't work well with, although it works fine with the default mode. – Scyrme (talk) 18:05, 6 April 2023 (UTC)
 * I don't think that it's supposed to. With perrow, you are essentially setting up a neat rectangular grid with consistent sizing and spacing. With packed, you are telling it to fit in as many as possible, and one row may not necessarily have the same number of images as the one above. -- Red rose64 &#x1f339; (talk) 21:20, 6 April 2023 (UTC)
 * I hadn't thought it through. It scales all the images to the same height, and the images are made however wide they have to be to scale them to that fixed height. This is also probably why "width" doesn't work; the template allows the image to occupy however much width it occupies when scaled to the set height.
 * What made me think of setting a maximum width was that the gallery can compete for space with sidebars and thumbnail images when there are particularly wide images relative to their height. When images are narrow, the gallery simply starts a new line, but it can't do that with a wide image so it instead gets forced out of the way, below other page elements, which creates a big empty void above the gallery.
 * This can be fixed by trial error to find the maximum height that doesn't cause this, but what I wanted was a way to skip the trial and error and have the template select an appropriate row height for the available width. Having thought about it more, having the template calculate a height from a width or perrow parameter would probably be too complicated to be feasible. – Scyrme (talk) 01:14, 7 April 2023 (UTC)

Request to update TemplateStyles
In recent times I found the MediaWiki reduced left margin of galleries for mobile phone, and the desktop view is unaffected. So I updated the TemplateStyles to match recent changes and keep title centered in this template, and I request to update TemplateStyles for current template. -- Great Brightstar (talk) 15:51, 3 April 2023 (UTC)
 * Red information icon with gradient background.svg Not done: I see several other changes besides the obvious adjustments to padding/margin that affected more than just the left margin. Can you please clarify each and why? Izno (talk) 17:59, 11 April 2023 (UTC)
 * OK I reverted some other experimental codes I've made, please take a look at. --
 * Great Brightstar (talk) 02:45, 13 April 2023 (UTC)

Centering glitch
As shown in Template:Gallery/testcases, the following markup does not center align the gallery

I have been working through this search to reduce Lint errors from Gallery centered using . While replacing it with  has mostly worked, there have been a few pages where it doesn't work for unknown reasons. ಮಲ್ನಾಡಾಚ್ ಕೊಂಕ್ಣೊ (talk) 15:30, 30 October 2022 (UTC)
 * I have added another set of test cases at Template:Gallery/testcases showing that margin:auto works for a single line of images but fails to align the gallery to the center when it wraps to more than one line. That may help someone to troubleshoot the situation shown above. – Jonesey95 (talk) 14:26, 14 November 2022 (UTC)


 * The following format is easier.

Peter Horn User talk 23:06, 30 December 2022 (UTC)
 * That looks nice. If the template can replicate that formatting, the bug might be fixed. – Jonesey95 (talk) 04:22, 31 December 2022 (UTC)
 * As a bonus it also centers the captions. Peter Horn User talk 02:34, 8 January 2023 (UTC)

Note: The OP's syntax uses the parameter lines, which it turns out is unsupported in this template. I have adjusted the relevant test cases on the testcases page to use perrow, and it looks like aligning is working well. Here's an example:

Note that this example aligns the gallery in the center. It does not align the captions. For that, use text-align:center, as shown on the testcases page. – Jonesey95 (talk) 16:40, 27 July 2023 (UTC)

Adjusting image heights in packed galleries
It is possible to adjust the heights of images using the gallery tag in "packed" mode:

But the  parameter seems to have no effect when the gallery template is in "packed" mode:

Why does the  parameter not work correctly here? Jarble (talk) 21:33, 2 August 2023 (UTC)
 * Fixed for you by removing "px" per the documentation. – Jonesey95 (talk) 12:42, 7 August 2023 (UTC)

Many parameters aren't documented here
Several of these parameters appear to be compatible with this template: why aren't they included in the template's documentation? Jarble (talk) 15:32, 27 July 2023 (UTC)
 * Please give an example, or you can edit the documentation yourself if you're feeling bold. – Jonesey95 (talk) 15:57, 27 July 2023 (UTC)
 * The  parameter seems to be compatible with this template, but the documentation doesn't mention it. Jarble (talk) 16:02, 27 July 2023 (UTC)
 * Thanks. I have added it to the documentation, and I took the opportunity to tidy the module and the testcases page a bit to remove unsupported parameters. I believe that the documentation lists all supported parameters now. – Jonesey95 (talk) 16:37, 27 July 2023 (UTC)
 * Is there an option to add a footer below the gallery or a frame around the gallery, as in Multiple image? Jarble (talk) 16:43, 2 August 2023 (UTC)
 * I think that we are limited to the options listed at Help:Gallery tag. I don't know for sure, though. – Jonesey95 (talk) 12:41, 7 August 2023 (UTC)
 * Alternatively, it's possible to put the gallery template inside an image frame with a caption below it. Jarble (talk) 20:03, 12 September 2023 (UTC)