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)
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)
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)
|
![]() | This edit request to Module:Gallery and Template:Gallery/styles.css has been answered. Set the |answered= parameter to no to reactivate your request. |
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 usedcaption
class in the module, making it useless, so I dropped it from TemplateStyles page. Second, I also discovered the module page have setline-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)
- OK, let me explain. First, for
- @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
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
![]() | This edit request to Template:Gallery/styles.css has been answered. Set the |answered= parameter to no to reactivate your request. |
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 edit request to Template:Gallery/styles.css has been answered. Set the |answered= parameter to no to reactivate your request. |
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:--Great Brightstar (talk) 20:44, 2 January 2021 (UTC)
.mod-gallery .bordered-images .thumb img { outline:solid #eaecf0 1px; border:none; }
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.
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)
- 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)
- It also seems that
- 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)
Request to update TemplateStyles
![]() | This edit request to Module:Gallery/styles.css has been answered. Set the |answered= parameter to no to reactivate your request. |
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]]''
}}
-
Galinha à Africana
-
Galinha à Portuguesa
-
Pastéis de nata
-
Pato de cabidela
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.
-
Galinha à Africana
-
Galinha à Portuguesa
-
Pastéis de nata
-
Pato de cabidela
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)
- That looks nice. If the template can replicate that formatting, the bug might be fixed. – Jonesey95 (talk) 04:22, 31 December 2022 (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]]''
}}
-
Galinha à Africana
-
Galinha à Portuguesa
-
Pastéis de nata
-
Pato de cabidela
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:
-
A Yeoman Warder, from a Victorian-era photochrom
-
The Official program of the 1913 Woman Suffrage Procession held in Washington, D.C.
-
Howard Thurston performing the Indian rope trick
-
"The Pirate Publisher", a satire of copyright infringement from the magazine Puck.
But the height
parameter seems to have no effect when the gallery template is in "packed" mode:
-
A Yeoman Warder, from a Victorian-era photochrom
-
The Official program of the 1913 Woman Suffrage Procession held in Washington, D.C.
-
Howard Thurston performing the Indian rope trick
-
"The Pirate Publisher", a satire of copyright infringement from the magazine Puck.
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)
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)
- @Jonesey95: The
perrow
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)
- @Jonesey95: 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)
- @Jonesey95: 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)
- 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)
- @Jonesey95: 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)
- 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)
- @Jonesey95: The
Question on default width / height
Hello,
Module:Gallery contains the following lines:
gargs['widths'] = tonumber(args.width) or 180
gargs['heights'] = tonumber(args.height) or 180
That sure makes it sound like the default width / height for traditional galleries is supposed to be 180x180. However, this is not actually true. Either gargs isn't being used at all, or else some other bit of parsing later on down the line throws it out, because the default gallery size end up being 120x120 if no width / height arguments are passed in. Is this a bug, or a feature? Where is the step that actually changes an unset widths / heights to 120?
(Context: I'm considering starting an RFC to change the default to something larger, but would like to know the technical constraints first. Maybe there's some deep issue with doing that or other problem to be aware of.) SnowFire (talk) 03:33, 9 September 2023 (UTC)
- To partially answer my own question: https://www.mediawiki.org/wiki/Manual:$wgGalleryOptions suggests that 120 is the default value at a MediaWiki-wide setting (confirmed at https://github.com/wikimedia/mediawiki/blob/master/includes/SetupDynamicConfig.php#L115-L123 ). So what is this gallery args default doing, anyway? If it was supposed to be setting widths & heights to 180 if unset, it's clearly not doing its job. Is this just a bug if 180x180 was always intended for English Wikipedia? (Note that I'm asking here because Module talk:Gallery redirects here...) If this functionality is bugged, that implies we need to go set the wgGalleryOptions at a lower config level rather than merely modify the Module code. SnowFire (talk) 18:06, 13 September 2023 (UTC)
- Before you start an RFC, you might consider requesting that a module editor modify the sandbox of this module, or other modules or code on which it depends, in a way that provides for a larger default image. As you appear to have deduced, starting an RFC could be a waste of time if it turns out that changing the default size is not possible. – Jonesey95 (talk) 19:41, 13 September 2023 (UTC)
- Are we sure that you are talking about
{{gallery}}
? Here is a comparison between<gallery>...</gallery>
and{{gallery}}
, both in minimal form:- Using
<gallery>...</gallery>
, these images render at 120×89 and 95×120:<gallery> Stephen Taber and the Rockland Breakwater.jpg|''Stephen Taber'' and the Rockland Breakwater Schooner Stephen Taber, around 1900.jpg | ''Stephen Taber'' anchored off Long Island c. 1900 </gallery>
- Using
- Using
{{gallery}}
, these images render at 182×135 and 144×182:{{gallery |File:Stephen Taber and the Rockland Breakwater.jpg|''Stephen Taber'' and the Rockland Breakwater |File:Schooner Stephen Taber, around 1900.jpg | ''Stephen Taber'' anchored off Long Island c. 1900 }}
- Using
- —Trappist the monk (talk) 21:44, 13 September 2023 (UTC)
- @Trappist the monk: I'm talking about <gallery>, not the template version. I'm asking here because, as noted above, Module talk:Gallery redirects to this Template talk page, so I presume this is intended to be the one place for gallery talk. The fact that the gallery tag has a different default than the template is... not good and surprising in a bad way, I don't think editors expect that. (Also as a slight nitpick, it's 180 not 182.) If this was unintentional, than it sounds like the Module is bugged if it's supposed to be using the same 180 as default.
- @Jonesey95: How exactly would I force an edited sandbox version to be used, though? Apologies if it's a dumb question, but I haven't ever attempted to force a Sandbox module to be used rather than the default SnowFire (talk) 03:02, 14 September 2023 (UTC)
- OK, now I'm confused. What is your goal? – Jonesey95 (talk) 13:25, 14 September 2023 (UTC)
- The extra 2px is the 1px boarder applied by the module with the
bordered-images
css class (Module:Gallery/styles.css line 76). - At Module:Gallery line 112 is this:
frame:extensionTag{ name = 'gallery', content = '\n' .. table.concat(gallery,'\n'), args = gargs}
- For my example gallery, that line creates a
<gallery>...</gallery>
tag that looks like this:<gallery class="nochecker bordered-images whitebg" heights="180" widths="180"> File:Stephen Taber and the Rockland Breakwater.jpg|Stephen Taber and the Rockland Breakwater File:Schooner Stephen Taber, around 1900.jpg|Stephen Taber anchored off Long Island c. 1900</gallery>
- Module:Gallery is overriding the 120px
<gallery>...</gallery>
tag default. If you want to change the<gallery>...</gallery>
tag default, this template/module is not the place to do it. Perhaps en.wiki has a configuration switch that can be changed increase<gallery>...</gallery>
tag default height/width. You might ask at WP:VPT. - —Trappist the monk (talk) 14:38, 14 September 2023 (UTC)
- Jonesey95: I'm trying to see what would be required to change the default behavior of the gallery tag, not the template.
- Trappist: So you're basically saying that the Module doesn't control the Gallery tag behavior at all, just this template? I see. Thanks for the information. (And yes, I know about the borders, but you said "these images render at 182×135" which sounded like you meant, well, the image itself.) SnowFire (talk) 18:59, 14 September 2023 (UTC)
- It sounds like you want to post at Help talk:Gallery tag. When you visit there, you may come across a link to this discussion, where, unfortunately, two changes were proposed at the same time, and one of them was opposed strongly, so the size increase did not happen. – Jonesey95 (talk) 20:55, 14 September 2023 (UTC)
- I'm afraid I came here from Help talk:Gallery tag, as you can see I already opened a section there awhile back ("Galleries, part 2"). I was under the impression that the Module code was where the tech-ier side lived hence asking here, but seems like that's not the case. And yes, I'm familiar with the earlier RFC, I'm referring to potentially running a second RFC strictly on size and not on packed vs. traditional, as noted on the linked talk page. I guess I'll keep looking to find where the config file used lives. SnowFire (talk) 15:51, 15 September 2023 (UTC)
- It sounds like you want to post at Help talk:Gallery tag. When you visit there, you may come across a link to this discussion, where, unfortunately, two changes were proposed at the same time, and one of them was opposed strongly, so the size increase did not happen. – Jonesey95 (talk) 20:55, 14 September 2023 (UTC)
- —Trappist the monk (talk) 21:44, 13 September 2023 (UTC)
- Perhaps this setting: mw:Manual:$wgGalleryOptions
- —Trappist the monk (talk) 18:30, 16 September 2023 (UTC)
- I'm familiar - it's linked in my second comment above. Hence why I said the real question is who to talk to change this and where the current config file for English Wikipedia is stored. SnowFire (talk) 00:02, 17 September 2023 (UTC)
- Module:Gallery is the underlying code of Template:Gallery, and this is the talk page for both. Their code is not used by
<gallery>...</gallery>
, which is an extension to the MediaWiki software. Changes to the latter are discussed at Help talk:Gallery tag. --Redrose64 🌹 (talk) 21:47, 17 September 2023 (UTC)
- Module:Gallery is the underlying code of Template:Gallery, and this is the talk page for both. Their code is not used by
- I'm familiar - it's linked in my second comment above. Hence why I said the real question is who to talk to change this and where the current config file for English Wikipedia is stored. SnowFire (talk) 00:02, 17 September 2023 (UTC)
Adjusting margins between images
See the discussion here: is it possible to remove the empty spaces between images in a gallery tag in "packed" mode? Jarble (talk) 16:07, 21 September 2023 (UTC)
Can I Use the Pie Chart Template inside of this Template?
I am trying to make 2 pie charts be right next to eachother, they are the same size. Can i use Template:Pie chart inside of the gallery template? 😎😎PaulGamerBoy360😎😎 (talk) 15:54, 14 December 2023 (UTC)
- I don't think so. You might have luck with {{Image frame}}. – Jonesey95 (talk) 19:31, 14 December 2023 (UTC)
Fix paddings for header and footer
![]() | This edit request to Module:Gallery/styles.css has been answered. Set the |answered= parameter to no to reactivate your request. |
Last year the <gallery> tag dropped large margin at the left side, and make use of px
unit instead to produce more compact view. So this template need to update to follow on. In this template I made changes for these three classes: mod-gallery-default
, title
, footer
. You can see the changes here, and you can also see the effects on c:Template:Gallery. -- Great Brightstar (talk) 16:37, 10 June 2024 (UTC)
Too white on dark mode. Can we get rid of white backgrounds?
The template uses a white background by default. This is too bright on dark mode. Removing this from the CSS fixes the issue:
.mod-gallery .whitebg .thumb { background: #fff !important; }
The default background color for a gallery is the same light grey as an infobox for the standard light theme. Rjjiii (talk) 03:55, 26 July 2024 (UTC)
Footer too small?
I tried testing it and couldn't quite tell, but I think the footer size may be in violation of MOS:SMALL. I can't seem to see the source code for the template to see if it is set at 85% or above, but to my eye it appears that it might be below that required threshold. Can I get confirmation whether it is indeed a violation or if I'm just seeing things? And of course, if it is indeed too small, then please adjust it. QuietHere (talk | contributions) 07:16, 26 July 2024 (UTC)
- You were correct. The footer text was at 80%. I have increased it to 85% per MOS:SMALLFONT. – Jonesey95 (talk) 19:12, 26 July 2024 (UTC)
Having trouble using the Gallery template with visual editor
It seems to be impossible to use the visual editor to add images to a gallery, you have to add the images elsewhere in the article, then switch to source mode to actually move them into the gallery; the template should be improved to be easier to use in the visual editor, for those who do not like using the source editor 2600:480A:5033:F601:E056:2C73:ED4D:E87D (talk) 23:02, 14 September 2024 (UTC)
- I don't use VE, but it looks like it might help to add
|1=
,|2=
, etc. to the TemplateData section of the documentation. Those are the parameters for the files and captions. – Jonesey95 (talk) 17:33, 16 September 2024 (UTC)
Tracking use of captionstyle
Why does the module track (line 23) the use of the captionstyle
parameter?
Are there any problems using it?
Thanks. Amadalvarez (talk) 06:55, 6 January 2025 (UTC)
class=skin-invert-image
NEMA connector § Harvey Hubbell's inventions has an issue with a gallery of diagrams that become invisible in dark mode. Help:Pictures § Dark mode talks about "class=skin-invert-image" as a workaround for individual pictures, but is there a way to apply CSS classes using this Gallery template? Indefatigable (talk) 20:20, 10 January 2025 (UTC)
- There is a way by wrapping it around a
<div class='skin-invert-image'> gallery </div>
- The problem is that in this way we can't invert specific images, it is all or nothing. When I was working on some pages, I would split in two galleries with one wrapped around the div, and other not. Sometimes there isn't a good option.
- This gallery template works by wraps around the
<gallery>
core parser extension tag, its a change I wouldn't expect anytime soon, but who knows? - To make it work through this template without a change to that core would require a lot of unconventional code. I have brainstormed and the options would be:
- - injecting a CSS for each gallery, and select the pictures to invert using
li:nth-child(image order number)
, probably a lot of work and I'm unsure if it would work. - - a javascript to apply the skin-invert. Probably a big no-no too.
- The other option is to add a white background to everything, but it is not ideal either.
- The best option I can think of is to implement in Template:Multiple image, it's much easier to be done in that template, and it's quite similar to this gallery.
- -- Arthurfragoso (talk) 04:51, 1 February 2025 (UTC)
- Thanks for looking into it. I'll see if "Multiple image" works in that article. Indefatigable (talk) 16:45, 1 February 2025 (UTC)
- I also tested to converting a gallery to "Multiple image" in an article and it was not easy. These templates are quite different. So I also checked, and there is an issue already in phabricator:T344784 that we can subscribe and follow. -- Arthurfragoso (talk) 17:22, 5 February 2025 (UTC)
- @Indefatigable and @Synpath, yesterday I got an idea for a workaround: adding some kind of non-visible marker to the filename, caption or alt text. With that I can select with the CSS.
- First I tried adding a div around caption with some class, and then I could use a "next-sibling" CSS selector, but wikipedia/mediawiki doesn't allow the css "has()" selector.
- I thought to add a # on front of images url to add a code, but
<gallery>
strips that. - I then thought to add some kind of non-printable character as a code. I could add it to the caption or alt text. The caption, besides it appearing bellow the image, it also appears in
<a title=caption>
. But if I added to the caption, there would be the risk of users selecting the text to copy, and pasting the non-printable character to other places, including to other captions. That would lead to other images being skin-inverted (bugs).
- So using it at the end of the alt text seems to be the option with the least prone to side effects, as those characters are just like spaces " ", and I could not think of better options until phabricator:T344784 is solved. After that the code could be changed to what they provide.
- It's working nice at: Template:Gallery/testcases#ClassN_/_Darkmode
- I think it would be fine, but I need to check for objections. Thoughts?
- -- Arthurfragoso (talk) 17:43, 6 February 2025 (UTC)
- Definitely a clever, working hack that can get fixed in one place rather than many after the underlying extension is updated. A potential problem is that the semantics of the class parameter is misleading as you can't apply any old CSS class. If there are other problems they're not obvious to me, but at least any visual effects would be limited to {{gallery}}'s on the same page as another (limited to the mod-gallery class).
- For the article Indefatigable linked, placing image thumbnails into columns and centering would do as a workaround, for example:
- A proper gallery implementation would be better, but this is a slightly more flexible way to layout images compared to multiple image ⇌ Synpath 02:26, 7 February 2025 (UTC)
{{col-begin|width=auto|style=margin: 0 auto;}} {{col-break}} [[File:220sb.svg|thumb|upright=0.7|center|class=skin-invert-image|NEMA 14-30 and 14-50 receptacles]] {{col-break}} [[File:NEMA 14-30 Dryer Receptacle.jpg|thumb|upright=0.7|center|NEMA 14-30 clothes dryer receptacle and plug]] {{col-break}} [[File:NEMA 14-50 outlet.jpg|thumb|upright=0.7|center|A NEMA 14-50 supplying 12 [[kilowatts|kW]] (9.6 kW sustained) on a 240 V circuit to recharge an [[Electric vehicle|EV]]]] {{col-end}}
- Thanks again @Synpath!
- The example you showed is great and helpful, at least for when there are few images.
- One of the advantages of the gallery is that it nicely adjust the items per row according to the available width of the screen that can be a bit tricky for mobile compatibility.
- There is no ideal solution, so I went ahead and I pushed the changes to production.
- About the semantics, I can better explain this in the template docs. The good thing is that once the underlining <gallery> gets fixed, the changes to {{gallery}} can be done seemly, so the semantics gets corrected. This, of course, is with the expectation that it would be someday implemented. -- Arthurfragoso (talk) 04:20, 7 February 2025 (UTC)
- @Arthurfragoso: Yeah I was thinking the semantics cuts both ways in that if the parameter was renamed it would have to be edited for each transclusion. Yesterday, I was looking for templates that implemented a flexbox and only found {{Flex columns}} which doesn't give an option to unset its default min-width and didn't think to just search for {{Flexbox}} which works better than what I suggested above:
- Looking at the brute force template wikitext got me thinking it should be relatively straight-forward to make an alternate gallery option as a Lua module that doesn't rely on the extension tag. Flexbox is kinda purpose-built for this kind of thing. The extension tag doesn't rely on flexbox and that makes sense for browser-compatibility, but flex has been widely supported for about 10 years now. ⇌ Synpath 15:04, 7 February 2025 (UTC)
{{Flexbox |min-width=150px |max-width=180px |padding=2px |style=justify-content: center; |1=[[File:220sb.svg|thumb|upright=0.7|center|class=skin-invert-image|NEMA 14-30 and 14-50 receptacles]] |2=[[File:NEMA 14-30 Dryer Receptacle.jpg|thumb|upright=0.7|center|NEMA 14-30 clothes dryer receptacle and plug]] |3=[[File:NEMA 14-50 outlet.jpg|thumb|upright=0.7|center|A NEMA 14-50 supplying 12 [[kilowatts|kW]] (9.6 kW sustained) on a 240 V circuit to recharge an [[Electric vehicle|EV]]]] }}
- And now I'm seeing {{Gallery items}} which allows you to apply skin-invert-image to single images:⇌ Synpath 15:24, 7 February 2025 (UTC)
{{Gallery items |width=180 |[[File:220sb.svg|180px|class=skin-invert-image]]|NEMA 14-30 and 14-50 receptacles |[[File:NEMA 14-30 Dryer Receptacle.jpg|180px]]|NEMA 14-30 clothes dryer receptacle and plug |[[File:NEMA 14-50 outlet.jpg|180px]]|A NEMA 14-50 supplying 12 [[kilowatts|kW]] (9.6 kW sustained) on a 240 V circuit to recharge an [[Electric vehicle|EV]] }}
- And now I'm seeing {{Gallery items}} which allows you to apply skin-invert-image to single images:
- @Arthurfragoso: Why do you say
wikipedia/mediawiki doesn't allow the css "has()" selector
? I use it in several rules at User:Redrose64/common.css, and it works as intended. --Redrose64 🌹 (talk) 19:15, 7 February 2025 (UTC)- Mediawiki seems to allows for user CSS, but for templatestyles, it goes through a css-sanitizer. It seems that it is because of some Mediawiki browser compatibility rules. If you test adding has() in Module:Gallery/sandbox/styles.css, it throws the error "Invalid selector list at line _ character _." and won't allow to save. -- Arthurfragoso (talk) 19:57, 7 February 2025 (UTC)
- Thanks for looking into it. I'll see if "Multiple image" works in that article. Indefatigable (talk) 16:45, 1 February 2025 (UTC)