Template talk:Gallery/Archive 2

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Archive 1 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? — 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 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 |whitebg=yes, and adding the class whitebg when the |whitebg= is undefined. I would expect the reverse. if your intention is to enable |whitebg=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 |whitebg=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. --Redrose64 🌹 (talk) 09:11, 18 May 2020 (UTC)
See here: Template:Gallery/testcases#Single image--Great Brightstar (talk) 09:17, 18 May 2020 (UTC)
So use [[File:Federal Hall NYC 27.JPG|thumb|upright|A statue of Washington|alt=Back of statue facing a city building whose facade is Greek columns covered by a huge U.S. flag]]. --Redrose64 🌹 (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)
 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 <gallery> 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 @media 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:
--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 — 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 — Martin (MSGJ · talk) 20:16, 26 May 2020 (UTC)
Where does the 720px come from? What is the reason for this value? — 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. — 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 {{URL|1=https://www.youtube.com/watch?v=56gzV0od6DU|2=Mandelbrot history}}, (c) use {{cite web|url=https://www.youtube.com/watch?v=56gzV0od6DU|title=Mandelbrot history}}, (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 whitebg 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:

{{gallery|Flag of Arkansas (1913).svg|81=Flag of Oklahoma (1925–1941).svg|93=Flag of South Carolina (January 1861).svg|92=[[Flag of South Carolina]]<br />(1775–January 26, 1861)|91=Flag of Fort Moultrie, South Carolina.svg|90=[[Flag of Rhode Island]]<br />(1882–97)|89=Flag of Rhode Island (1882–1897).svg|88=[[Flag of Rhode Island]]<br />(1877–82)|87=Flag of Rhode Island (1877–1882).svg|86=[[Flag of Oklahoma]]<br />(1988–2006)|85=Flag of Oklahoma (1988–2006).svg|84=[[Flag of Oklahoma]]<br />(1941–1988)|83=Flag of Oklahoma (1941–1988).svg|82=[[Flag of Oklahoma]]<br />(1925–1941)|80=[[Flag of Oklahoma]]<br />(1911–25)|95=Flag of South Carolina (1861).svg|79=Flag of Oklahoma (1911–1925).svg|78=[[Flag of North Carolina]]<br />(March 1885–June 24, 1991)|77=Flag of North Carolina (1885-1991).svg|76=[[Flag of Nevada]]<br />(1929–July 25, 1991)|75=Flag of Nevada (1929-1991).svg|74=[[Flag of Nevada]]<br />(1915–1929)|73=Flag of Nevada (1915-1929).png|72=[[Flag of Nevada]]<br />...

😲 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. --Redrose64 🌹 (talk) 17:16, 1 July 2020 (UTC)
Ah, thank you for the explanation Redrose64 🌹, 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 colourful 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)

@Great Brightstar: There seem to be other changes in the sandbox, e.g. .mod-gallery .caption. Are these related to this request? — Martin (MSGJ · talk) 08:20, 17 September 2020 (UTC)
OK, let me explain. First, for .mod-gallery .caption, that's actually not related to the request, but is due to my discovery after my change. I haven't seen any element used caption class in the module, making it useless, so I dropped it from TemplateStyles page. Second, I also discovered the module page have set line-height 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 .mod-gallery .title>div * 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. — Martin (MSGJ · talk) 11:43, 18 September 2020 (UTC)
@MSGJ: 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.
	if args.align then
		tbl:addClass('mod-gallery-' .. args.align:lower())
	end
-- Great Brightstar (talk) 12:14, 18 September 2020 (UTC)
 Done — 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)#Field Army but have not had any success. Is it possible to use the two together? Any help much appreciated! @MSGJ:Brigade Piron (talk) 10:57, 19 September 2020 (UTC)

@Brigade Piron: 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 <gallery> (it should be </gallery>). 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 mod-gallery-default class, the margin-top property should be modified using em unit, like this:

.mod-gallery-default {
	background:transparent;
	margin-top:.3em;
}

-- Great Brightstar (talk) 18:42, 30 October 2020 (UTC)

 Done 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)

 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. — JJMC89(T·C) 20:11, 2 January 2021 (UTC)
So let's see my fix:
.mod-gallery .bordered-images .thumb img {
	outline:solid #eaecf0 1px;
	border:none;
}
--Great Brightstar (talk) 20:44, 2 January 2021 (UTC)
 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 MediaWiki talk:Common.css § Preview warning and hatnotes moving to TemplateStyles Izno (talk) 00:22, 29 April 2021 (UTC)

Faulty "packed" mode?

Does |width= 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.

Examples at 600 px

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 tc 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 |perrow= doesn't work well with |mode=packed, 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. --Redrose64 🌹 (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)

 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

{{Gallery
|width=175
|align=center
|File:African chicken macau.JPG|''Galinha à Africana''
|File:Galinha à Portuguesa.jpg|''Galinha à Portuguesa''
|File:MargaretCafe PasteisDeNata.JPG|''Pastéis de nata''
|File:PortoExterior PatoDeCabidela.JPG|''Pato de cabidela''
|File:Minchi.jpg|''[[Minchi]]''
}}

I have been working through this search to reduce Lint errors from {{Gallery}} centered using <center>...</center>. While replacing it with |align=center 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#Centering using style parameter showing that |style=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:

{{Gallery
|width=175
|align=center
|perrow=2
|File:African chicken macau.JPG|''Galinha à Africana''
|File:Galinha à Portuguesa.jpg|''Galinha à Portuguesa''
|File:MargaretCafe PasteisDeNata.JPG|''Pastéis de nata''
|File:PortoExterior PatoDeCabidela.JPG|''Pato de cabidela''
|File:Minchi.jpg|''[[Minchi]]''
}}

Note that this example aligns the gallery in the center. It does not align the captions. For that, use |style=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 height parameter seems to have no effect when the gallery template is in "packed" mode:

Why does the height 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)