Template talk:Infobox
![]() | Template:Infobox is permanently protected from editing because it is a heavily used or highly visible template. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify an administrator or template editor to make the requested edit. Usually, any contributor may edit the template's documentation to add usage notes or categories.
Any contributor may edit the template's sandbox. Functionality of the template can be checked using test cases. |
This is the talk page for discussing improvements to the Infobox template. |
|
Archives: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19Auto-archiving period: 3 months ![]() |
![]() | This template does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||
|
![]() | Text has been copied to or from this page; see the list below. The source pages now serve to provide attribution for the content in the destination pages and must not be deleted as long as the copies exist. For attribution and to access older versions of the copied text, please see the history links below.
|
Related pages |
---|
Template-protected edit request on 22 July 2024
[edit]![]() | This edit request to Module:Infobox has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Hi there I hope you are doing well! I would like to add an additional image from The [1]PBC Coat of Arms under the main image using the actual template. Precisely, I would like to edit as I want this page without prior demand or requirements. If you could include my tag-name in the allowed list, I would greatly appreciate it. Best regards, Sir Watson SirlupinwatsonIII (talk) 05:03, 22 July 2024 (UTC)
Not done: this is the talk page for discussing improvements to the template
{{Infobox}}
. Please make your request at the talk page for the article concerned. Primefac (talk) 12:24, 22 July 2024 (UTC)
Logos and dark mode
[edit]Is it possible to set a white (or an offwhite) background colour fill by default for logos in dark mode? Logo images with transparent background may not work well with dark mode, i.e. Taiwan Power Company. – robertsky (talk) 18:36, 25 August 2024 (UTC)
- Maybe it's just my computer, but I see the image in question inside of a white box (though when I go directly to the file page itself, it shows a transparent background). Primefac (talk) 20:24, 25 August 2024 (UTC)
- That's what I see too. I agree the black background does not make it easy to see the logo — Martin (MSGJ · talk) 20:36, 25 August 2024 (UTC)
- Which do you see? A black background in the infobox, or a white background in the infobox? Just noting that both options have been indicated above. Primefac (talk) 20:48, 25 August 2024 (UTC)
- I see the white background in the infobox and the transparent background on the file itself, which I interpreted to be the same as you — Martin (MSGJ · talk) 20:50, 25 August 2024 (UTC)
- Which do you see? A black background in the infobox, or a white background in the infobox? Just noting that both options have been indicated above. Primefac (talk) 20:48, 25 August 2024 (UTC)
- That's what I see too. I agree the black background does not make it easy to see the logo — Martin (MSGJ · talk) 20:36, 25 August 2024 (UTC)
- It cannot be done from the core styles today. (That might be possible later, I haven't decided. Feedback somewhere between fine and welcome.)
- You will need to provide an appropriate class to the image row to indicate it holds an icon, and then you will need to add TemplateStyles to the infobox to make the image background always the light background. In order:
- Add a class to the row. In infobox company's case, there is already a
logo
class, but I do not know from what this stems, so I will add toib-company-logo
- Add
|templatestyles=Infobox company/styles.css
- Create Template:Infobox company/styles.css with the CSS
.ib-company-logo img { background-color: #f8f9fa; }
- Save all the pages + protection for the TemplateStyles page.
- Add a class to the row. In infobox company's case, there is already a
- IDK about MSGJ and Primefac. The relevant dark mode here is the WMF standard dark mode, which only now post-my-edit displays the image with a light background. Izno (talk) 20:58, 25 August 2024 (UTC)
- @Izno thanks! yeah... I should have had specified that it is the WMF standard dark mode. Thanks to @MSGJ and @Primefac for responding as well. – robertsky (talk) 02:35, 26 August 2024 (UTC)
- While Infobox company is updated, the other Infoboxes will have to be updated as well, i.e. {{Infobox Indian political party}}. See Dravida Munnetra Kazhagam for example. I guess I will hunker down and see what other Infoboxes have to be updated or adjusted. (i.e {{Infobox baseball league division series}} may have to be updated to have the logo parameter to account for the use of logos in the image parameter, i.e. 2003 American League Division Series or 2002 National League Division Series. – robertsky (talk) 06:31, 26 August 2024 (UTC)
implementing optional image/caption
[edit]Hi there, I hope this is a good place to ask. Does preprocessArgs({ {prefix = 'image', depend = {'caption', 'imagerowclass'}} }, 10) mean that for an image26 + caption26 to show up, we have to have an imagerowclass26, or something similar?
My problem is that {{Infobox mountain/sandbox}} refuses to render that, and there's no errors shown, so I'm at a loss. The logic over there is a fair bit convoluted - we want to shift indices in case a photo is present, and the photo can also be present at Wikidata, so we call {{#invoke:WikidataIB|getValue}} for the latter. But even if I set up image26 and caption26 statically, it's not rendered. How come?
Obviously, if all this is barking up the wrong tree and there's a simpler way to get the same result, I'm all ears.
TIA! --Joy (talk) 15:25, 8 October 2024 (UTC)
- To answer the first question, no, "depend" is the other direction: to have an imagerowclass or a caption you must first have an image. Izno (talk) 16:06, 8 October 2024 (UTC)
- Thanks.
- Is it possible that this dynamic row creation behavior of infobox mountain depends on preprocessArgs step, which in case of dataN can be 50 or so apart, but imageN can only be 10 or so apart, or something like that? --Joy (talk) 20:00, 8 October 2024 (UTC)
- OK that should be it. I think I missed the fact that imageN is not supposed to be interleaved with dataN, but necessarily above them. IOW despite this content ultimately being an image, it'll have to be implemented through data rows? --Joy (talk) 20:31, 8 October 2024 (UTC)
- I was fairly certain this was a restriction but wanted to see if anyone else piped up. Yes, images go at the top of the infobox, that's always where they've gone, and where other infoboxes support an image elsewhere it's with a data cell, no label, because they were shoehorned in. Izno (talk) 20:41, 8 October 2024 (UTC)
- OK, makes sense. The only reason I went for the image+caption syntax was that it seemed logical for that separation of rows, but if there's no real difference between imageN+captionN and dataN+data(N+1), it's just fine to keep using the latter for this. --Joy (talk) 21:01, 8 October 2024 (UTC)
- I was fairly certain this was a restriction but wanted to see if anyone else piped up. Yes, images go at the top of the infobox, that's always where they've gone, and where other infoboxes support an image elsewhere it's with a data cell, no label, because they were shoehorned in. Izno (talk) 20:41, 8 October 2024 (UTC)
- OK that should be it. I think I missed the fact that imageN is not supposed to be interleaved with dataN, but necessarily above them. IOW despite this content ultimately being an image, it'll have to be implemented through data rows? --Joy (talk) 20:31, 8 October 2024 (UTC)
Rowstyle question
[edit]Is there any reason why |rowstyle=
doesn't show borders in dark mode as seen at the Washington Commanders? ~ Dissident93 (talk) 02:51, 14 November 2024 (UTC)
- WMF styles are oppressive it seems. That's it, that's the story. Izno (talk) 02:54, 14 November 2024 (UTC)
- I'm assuming it's no easy fix then. ~ Dissident93 (talk) 03:24, 14 November 2024 (UTC)
- Not without issues in other ways. Izno (talk) 03:54, 14 November 2024 (UTC)
- I'm assuming it's no easy fix then. ~ Dissident93 (talk) 03:24, 14 November 2024 (UTC)
Parameters with space in the name
[edit]There might be some valid reasons why two-word parameter names to be spelled with an underscore in the middle, but I would like to propose an easy-to-implement idea of adding a simple input preprocessor to accommodate the users who cannot memorize which template expects an underscore and which expects a space.
As this preprocessor is meant to be added in front (without '|list'), without requiring any change in the tried-and-tested template itself, implementation should be simpler than making many changes in different locations:
{{#invoke:params|renaming_by_replacing|%s|_|1|list}}
On Chrome browser, the character following '%s|' in the above line appears indistinguishable from a space, but it is an underscore. This symptom might further highlight the benefit of adding this preprocessor. If a space is found in the middle of parameter names, this line replaces it with an underscore (only once on each parameter name, for as many parameters there may be). It leaves single-word parameter names and those parameter names spelled with underscore as is, and it is meant only for those templates that expect an underscore. As a result of adding the line, the template will accept a space where an underscore is expected to join two words in parameter names.
What I don't know is where and how best to place it, if it is possible and desirable to place it on Template:Infobox to take care of its child templates at once, or on each child like Template:Infobox Treaty. And further I don't know if any child template uses parameter names with a space. I would help in editing the doc pages for the change if needed.
Yiba (talk | contribs) 16:29, 12 February 2025 (UTC)
- Feel free to implement this in a sandbox template or module and show how it works. You'll need to account for all sorts of bad choices by template editors. For example: What happens in the degenerate case where there are two distinct parameters, one with a space and one with an underscore but otherwise identical? – Jonesey95 (talk) 19:04, 12 February 2025 (UTC)
- Thanks. May be a bit difficult to read, but a demo is at: User:Yiba/sandbox/infobox
- In this demo, parameters "former_name=Former Name" and "former name=degenerate case" are specified. The first parameter with an underscore is unchanged, and the second parameter is changed by the above line to "former_name=degenerate case" ending up two parameters with the same name. When this occurs, the 'changed' parameter name takes precedence, as it is the spec for "params|renaming by replacing", so the original "former_name=Former Name" is discarded with no harm done.
- In an even more foolish case where "|former_name=Former Name|" and "|former name=|" are specified, "former name" is converted into "former_name" and passed without data, with no harm.
- In the most degenarate case where "|former name|" is in the line, '1' is prepended as the param name and "1=former name" (without being converted, as neither 'former' nor 'name' is considered as a param name) is passed. As '1' is unknown to Template:Infobox Treaty as a parameter name, it is ignored without harm.
- I cannot figure out how to incorporate the line into the template, but as I am not a template editor, I'd need your further help regardless. Yiba (talk | contribs) 04:11, 13 February 2025 (UTC)
- An easy solution is to just change the templates that use spaces. Gonnym (talk) 11:42, 13 February 2025 (UTC)
- Do you know the reason why this template uses underscore, and not the space? I feel there are much more templates, especially those frequently used for editing, that use space rather than underscore. Yiba (talk | contribs) 01:11, 18 February 2025 (UTC)
- MOS:INFOBOXNAME:
Use snake case (e.g.
and|birth_date=
). Not camel case (e.g.|birthDate=
) or title case (e.g.|BirthDate=
)represent spaces using an underscore, e.g.
.Gonnym (talk) 09:42, 18 February 2025 (UTC)|birth_place=
not|birth-place=
or|birth place=
- There are a few parameter names in {{infobox}} itself that should be converted to snake, fwiw. Primefac (talk) 14:58, 18 February 2025 (UTC)
- Thank you. Now I understand changing Infobox spec may be a daunting task.
- However:
- 1. "Better for the users" should take priority over "easier to code".
- 2. Manuals are written about something pre-existing. Infobox was coded before the manual was written, and its features were not determined because the manual said so.
- 3. As I have stated, I am willing to rewrite docs, including the MOS if necessary.
- 4. My proposal does not subtract any functionality.
- 5. The proposal does accommodate users better.
- What do you think? Yiba (talk | contribs) 02:46, 20 February 2025 (UTC)
- I disagree that spaces are better. Gonnym (talk) 09:48, 20 February 2025 (UTC)
- I am not saying space is better. I am saying accepting underscore AND space is more user-friendly. This proposal does not reduce convenience for the users who prefers underscore. Yiba (talk | contribs) 00:25, 21 February 2025 (UTC)
- I'll be blunt and say I don't care what a specific user prefers or does not prefer. We should have one consistent style (whichever it may be) and use that. That isn't something unique to Wikipedia. Every good language has a naming convention. This allows everyone using the system to know what to expect. Gonnym (talk) 10:44, 21 February 2025 (UTC)
- I understand Wikipedia is many different things for different people. But I am sure it was and is NOT meant for the use by programmers (unlike programming tools). The English language uses space (or, sometimes hyphen) in between words, so if we have to standardize and choose between a space and underscore, the choice is clear that it should be the space.
- I am not arguing for standardization, but for the vast majority of English-speaking users and editors of en.wikipedia, a natural expectation would be the system to accept a space connecting two-word names. I don't mind the system expecting an underscore, but allowing the use of space (in addition to underscore) is more user-friendly. Yiba (talk | contribs) 05:51, 25 February 2025 (UTC)
- I'll be blunt and say I don't care what a specific user prefers or does not prefer. We should have one consistent style (whichever it may be) and use that. That isn't something unique to Wikipedia. Every good language has a naming convention. This allows everyone using the system to know what to expect. Gonnym (talk) 10:44, 21 February 2025 (UTC)
- I am not saying space is better. I am saying accepting underscore AND space is more user-friendly. This proposal does not reduce convenience for the users who prefers underscore. Yiba (talk | contribs) 00:25, 21 February 2025 (UTC)
- I disagree that spaces are better. Gonnym (talk) 09:48, 20 February 2025 (UTC)
- MOS:INFOBOXNAME:
- Do you know the reason why this template uses underscore, and not the space? I feel there are much more templates, especially those frequently used for editing, that use space rather than underscore. Yiba (talk | contribs) 01:11, 18 February 2025 (UTC)
Forcing a bg color on images with transparent bg
[edit]Some images with white elements on transparent background become illegible when used in infoboxes. Is there a way to force a background color behind the image so that the white parts could contrast against it and become legible? If there isn't a way, I think there should be. I know at least 2 cases where it would be immensely useful. —CX Zoom[he/him] (let's talk • {C•X}) 09:36, 24 February 2025 (UTC)
- See Help:Pictures#Dark mode and this more detailed discussion. Does that help? – Jonesey95 (talk) 16:07, 25 February 2025 (UTC)
- They don't seem to deal with what I need. I need help with the original version of European Aquatics logo. As you can see, the white text on transparent background fails to provide any contrast at all with the white page. But since it was an .svg file, I forced a background color by tweaking the file code, so it now has contrast. Second is File:2025 Kabaddi World Cup (WK).webp: it's white elements again get mixed in the infobox where it has been used. But since its .webp, I have no clue if it even is possible to hardcode a background color into the file. In either case, it will be more desirable to choose a background on a case-by-case basis rather than forcing a background color into the file code. Thanks! —CX Zoom[he/him] (let's talk • {C•X}) 16:22, 25 February 2025 (UTC)
- This template's documentation says that
|imagestyle=
may help you. – Jonesey95 (talk) 16:47, 25 February 2025 (UTC)
- This template's documentation says that
- They don't seem to deal with what I need. I need help with the original version of European Aquatics logo. As you can see, the white text on transparent background fails to provide any contrast at all with the white page. But since it was an .svg file, I forced a background color by tweaking the file code, so it now has contrast. Second is File:2025 Kabaddi World Cup (WK).webp: it's white elements again get mixed in the infobox where it has been used. But since its .webp, I have no clue if it even is possible to hardcode a background color into the file. In either case, it will be more desirable to choose a background on a case-by-case basis rather than forcing a background color into the file code. Thanks! —CX Zoom[he/him] (let's talk • {C•X}) 16:22, 25 February 2025 (UTC)

- Your solution is perfect on my mobile device. But, it fails on my Windows desktop (both Chrome and Edge). On desktop, the image appears as a white box inside a green box, no different from what it would be like if image background was set to white. —CX Zoom[he/him] (let's talk • {C•X}) 18:25, 25 February 2025 (UTC)
- I can't explain that. It works for me on Firefox and Brave and Safari for Mac (desktop), and the image appears to be transparent on its file page. It might be worth filing a bug on Phabricator for that one. – Jonesey95 (talk) 19:14, 25 February 2025 (UTC)
- It appears that the full-size thumbnail retains the transparency while other sizes have no transparency. On my system (Linux), viewing the page with Firefox or Chromium uses a 220px thumbnail that has no transparency, while in Firefox hitting Ctrl+Shift+M ("responsive design mode") displays the full-size 372px thumbnail which retains the transparency. If I change my thumbnail size preference to 400px, that also uses the full-size 372px thumbnail and so retains the transparency. Anomie⚔ 12:58, 26 February 2025 (UTC)
- It seems that even when setting image to 250px, it works correctly on Windows. See Special:Diff/1277746496. Is it working on Linux as well? —CX Zoom[he/him] (let's talk • {C•X}) 13:39, 26 February 2025 (UTC)
- I'm seeing a white-backgrounded image at that link. Anomie⚔ 01:30, 27 February 2025 (UTC)
- Can you please change it to a size that provides the expected output on your screen? I'll check on my side if it works. —CX Zoom[he/him] (let's talk • {C•X}) 12:40, 27 February 2025 (UTC)
- I'm seeing a white-backgrounded image at that link. Anomie⚔ 01:30, 27 February 2025 (UTC)
- It seems that even when setting image to 250px, it works correctly on Windows. See Special:Diff/1277746496. Is it working on Linux as well? —CX Zoom[he/him] (let's talk • {C•X}) 13:39, 26 February 2025 (UTC)
- It appears that the full-size thumbnail retains the transparency while other sizes have no transparency. On my system (Linux), viewing the page with Firefox or Chromium uses a 220px thumbnail that has no transparency, while in Firefox hitting Ctrl+Shift+M ("responsive design mode") displays the full-size 372px thumbnail which retains the transparency. If I change my thumbnail size preference to 400px, that also uses the full-size 372px thumbnail and so retains the transparency. Anomie⚔ 12:58, 26 February 2025 (UTC)
- I can't explain that. It works for me on Firefox and Brave and Safari for Mac (desktop), and the image appears to be transparent on its file page. It might be worth filing a bug on Phabricator for that one. – Jonesey95 (talk) 19:14, 25 February 2025 (UTC)
- Your solution is perfect on my mobile device. But, it fails on my Windows desktop (both Chrome and Edge). On desktop, the image appears as a white box inside a green box, no different from what it would be like if image background was set to white. —CX Zoom[he/him] (let's talk • {C•X}) 18:25, 25 February 2025 (UTC)