Module talk:InfoboxImage

Latest comment: 4 months ago by Gonnym in topic Explicit option to not add image

Category:Pages using deprecated image syntax nominated for deletion edit

Please see this CfD discussion about Category:Pages using deprecated image syntax. – Jonesey95 (talk) 01:38, 7 October 2020 (UTC)Reply

Broken title parameter in frameless mode if it includes CSS edit

If the title parameter includes CSS (e.g., via the {{legend}} template), then it displays the plain-text CSS rules into the map tooltip and the image description in the image popup (i.e., the Lightbox-style image mode that pops up after clicking on the image). This is strange considering invoking the image using the [[File:]] syntax directly (in the default mode) doesn't seem to have this issue, but using it in the frameless mode does:

[[File:Individual Taxation Systems.svg|left|thumb|300px|Systems of taxation on personal income {{legend|#00FF00|No income tax on individuals}} {{legend|#0080FF|Territorial}} {{legend|#000080|Residence-based}} {{legend|#FF00FF|Citizenship-based}}]]:

 
Systems of taxation on personal income
  No income tax on individuals
  Territorial
  Residence-based
  Citizenship-based

[[File:Individual Taxation Systems.svg|left|frameless|thumb|300px|Systems of taxation on personal income {{legend|#00FF00|No income tax on individuals}} {{legend|#0080FF|Territorial}} {{legend|#000080|Residence-based}} {{legend|#FF00FF|Citizenship-based}}]]:

 
Systems of taxation on personal income
  No income tax on individuals
  Territorial
  Residence-based
  Citizenship-based

{{#invoke:InfoboxImage|InfoboxImage|image=Individual Taxation Systems.svg|size=300px|upright=1.15|alt=Text|title=Systems of taxation on personal income {{legend|#00FF00|No income tax on individuals}} {{legend|#0080FF|Territorial}} {{legend|#000080|Residence-based}} {{legend|#FF00FF|Citizenship-based}}}}:

 

Getsnoopy (talk) 20:23, 26 December 2020 (UTC)Reply

@Getsnoopy: frameless does not have a caption. See Wikipedia:Extended image syntax#Alt text and caption. The parameter is used for the link title instead. A link title is displayed as plain text. Module:InfoboxImage could examine title and omit using it as link title if it doesn't look like plain text. A tracking category could be added instead. PrimeHunter (talk) 11:41, 13 March 2021 (UTC)Reply
I've update the code to not use the title param if it contains templatestyles. -- WOSlinker (talk) 15:52, 13 March 2021 (UTC)Reply

Template-protected edit request on 8 June 2021 edit

I would like to have Judge Rose's photo on her Wikipedia profile page updated. I'm passing this request along from Judge Rose herself. I have an updated photo from her that I can send to you but wanted to confirm that I'm in the right place to request this change. 8thcirc (talk) 19:04, 8 June 2021 (UTC)Reply

To editor 8thcirc:   Not done: this is the talk page for discussing improvements to the page Module:InfoboxImage. If possible, please make your request at the talk page for the article concerned. If you cannot edit the article's talk page, you can instead make your request at Wikipedia:Requests for page protection#Current requests for edits to a protected page. P.I. Ellsworth  ed. put'r there 22:55, 8 June 2021 (UTC)Reply

none options for link and alt edit

We should probably add none options for link and alt. It would be useful in places such as {{archives}} but likely other non-infobox templates using this as well since this is the most versetile image handling template. --Trialpears (talk) 15:14, 11 August 2021 (UTC)Reply

Seems like a good idea. -- WOSlinker (talk) 21:10, 11 August 2021 (UTC)Reply

Module breaks when there are multiple images on Wikidata edit

In a recent edit the Module broke because there were three different images set on Wikidata, and the Module tried interpreting them as one, which doesn't work. Is there a way to recognize this and use them all separately? -- Asartea Talk | Contribs 15:49, 29 August 2021 (UTC)Reply

Module update edit

I've done some work in the sandbox. The original intent was to add an error category for when URL links are used for images, as currently it just returns an empty string. While working on the code I've also cleaned up the code, including:

  • Consistent spaces
  • Consistent usage of quotation marks
  • Using table.param instead of table["param"]
  • Reordering the placeholder_image table alphabatically
  • Removing ";" from the end of lines as Lua does not use that.

I've replaced the following block of code at Module:InfoboxImage#L-144:

    if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "http:" then
        return "";
    end
    if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "[http:" then
        return "";
    end
    if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[[http:" then
        return "";
    end
    if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "https:" then
        return "";
    end
    if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[https:" then
        return "";
    end
    if mw.ustring.lower(mw.ustring.sub(image,1,8)) == "[[https:" then
        return "";
    end

with Module:InfoboxImage/sandbox#L-137:

	if string.find(image, "^%[*http") then
		-- Error category.
		return "[[Category:Pages using infoboxes with url links]]"
	end

I've added URL testcases to Module:InfoboxImage/testcases. The new tests and all previous tests pass Module talk:InfoboxImage/testcases.

Please let me know if you have comments or questions. Gonnym (talk) 09:04, 2 October 2021 (UTC)Reply

There are quite a few images at commons whose names begin with the letters "http". Will this code drop them into the error category? Perhaps "^%[*https?:" would be safer, if that's the correct regex syntax for string.find -- John of Reading (talk) 09:21, 2 October 2021 (UTC)Reply
I've added a test for an image from commons that starts with HTTP and it worked. That said I've also now updated the sandbox with your suggested code to make it more correct. Gonnym (talk) 09:35, 2 October 2021 (UTC)Reply

Why is "alt" the fallback for "title"? edit

In this condition

if title ~= "" and title ~= nil then
    result = result .. "|" .. title;
elseif alt ~= "" and alt ~= nil then
    result = result .. "|" .. alt;
end

|alt= is used as the fallback for an image title when |title= is not present. This appears arbitrary to me and it diverges from the usual behavior of |alt= in [[File:]] constructs. As a result, articles that use InfoboxImage and alt (but not title) for each image suddenly have a title on the infobox image, but none on all others. Is there a reason that this is the case? Can this behavior be corrected (by removing lines 271 and 272)? IceWelder [] 07:38, 26 October 2021 (UTC)Reply

Not sure whether anyone is even watching this talk page. @WOSlinker: You're the most active editor on the module. Would you mind sharing your insight? IceWelder [] 17:22, 27 October 2021 (UTC)Reply
It was just done that way so that the hover over tooltip showed some information. If there are no objections in the next week then I'll remove it. -- WOSlinker (talk) 18:29, 27 October 2021 (UTC)Reply
I've updated it. -- WOSlinker (talk) 18:26, 5 November 2021 (UTC)Reply
I made this corresponding doc update https://en.wikipedia.org/w/index.php?title=Module:InfoboxImage/doc&type=revision&diff=1065533441&oldid=1048551125&diffmode=source Note that lines 259-262 now seem redundant
        -- if alt value is a keyword then do not use as a description
        if alt == "thumbnail" or alt == "thumb" or alt == "frameless" or alt == "left" or alt == "center" or alt == "right" or alt == "upright" or alt == "border" or mw.ustring.match(alt or "", '^[0-9]*px$', 1) ~= nil then
            alt = nil;
        end
Arlolra (talk) 01:58, 14 January 2022 (UTC)Reply

Template-protected edit request on 8 March 2022 edit

Please apply the changes made to the module in Module:InfoboxImage/sandbox (diff), which adds the option for a "class" parameter that allows upper templates to set an HTML class for the infobox image (particularly the newly-introduced "notpageimage" class, which removes the image from the list of page images). Testcase of working usage of the parameter is shown at the right side (you may need to use the browser's element inspector to verify that the class exists). Chlod (say hi!) 09:47, 8 March 2022 (UTC)Reply

  Done -- WOSlinker (talk) 19:18, 13 March 2022 (UTC)Reply
Chlod I think it would make more sense for this module to provide an API to add the class(es) of interest rather than to provide a class parameter that we'll have to chase the name down should the name ever change. (Or for any other reason.) Izno (talk) 03:25, 14 March 2022 (UTC)Reply

Help with improving default image sizes edit

A few editors had a contentious but thoughtful discussion about default image sizes in infoboxes that fizzled out due to lack of technical expertise; see this discussion from July 2022. It looks like the next step was to post a request for help here. Basically, we thought that this module might be able to do a better job of providing images for infoboxes that followed editors' thumb size preferences so that we could move away from fixed pixel size specifications in infoboxes. If there is anyone here who is willing to look into how we might default to frameless (or whether the module already does this, and how to code infobox image calls properly), I would be grateful. – Jonesey95 (talk) 01:03, 10 January 2023 (UTC)Reply

Ditto. On some other wikis you format the image inside the info box, and can just use 'upright' to size, but on WP-en it's too complicated for me to figure out. It would be nice if at e.g. the language infobox we could set the default to, say, upright=0.9, and editors could override with their own upright value if they chose.

Is it possible to set the infobox width to match the user's default image size, or would that be a bad idea? — kwami (talk) 01:45, 10 January 2023 (UTC)Reply

Perhaps I am misunderstanding the discussion or request. There is already a parameter |upright= to this Module, which is passed along to the [[Image:XXX]] wikitext. If you want an infobox image to default to 114% of the size of a user's preference, why not just set |upright=1.14 in the infobox code? What am I missing? — hike395 (talk) 03:51, 10 January 2023 (UTC)Reply
In my case, that I don't know what I'm doing with this module! — kwami (talk) 03:53, 10 January 2023 (UTC)Reply
Is there a specific infobox we can try to improve? Maybe that will make things clearer (or maybe there will an unanticipated problem and we'll learn from the attempt). — hike395 (talk) 03:55, 10 January 2023 (UTC)Reply
Yes, thank you. {{Infobox language}}, which I could then extend to Infobox language family. — kwami (talk) 03:57, 10 January 2023 (UTC)Reply
Is the idea to default to |upright=0.9 (~200/220) ? Let's try it in the sandbox. — hike395 (talk) 03:58, 10 January 2023 (UTC)Reply
Currently, 'image' is set to 90% and 'map' to 100%. — kwami (talk) 03:59, 10 January 2023 (UTC)Reply
Looks like it worked, see Template:Infobox language/testcases. My default image size is 250px, and it clearly changed for me. It still allows fixed-size overriding, but the default will obey user preferences. Hopefully this will resolve the dispute that seemed to happen at Template talk:Infobox bridge/Archive 2?
I'll leave it to other editors to get consensus on this change, but it seems to work technically. — hike395 (talk) 04:07, 10 January 2023 (UTC)Reply
Thanks!
Would it be possible to set it so that if we enter, say, 'mapsize' or 'imagesize=1.25', it will set it as upright=1.25, so we don't have to use px? — kwami (talk) 04:18, 10 January 2023 (UTC)Reply
I guess we could check to see if the mapsize is <4, use it as upright? I worry that this will be confusing to editors. — hike395 (talk) 05:56, 10 January 2023 (UTC)Reply

It looks like using |upright= will generally work, as shown at Template:Infobox bridge/testcases (set your thumbnail preference to 300px or higher to see the difference). Somewhere (I forget where, unfortunately), an editor chose to specify an infobox image size to match the pixel size of the mapframe map in the infobox. I don't see a way to apply |upright= to mapframe maps, so I posted a query at the relevant talk page. – Jonesey95 (talk) 05:04, 10 January 2023 (UTC)Reply

Anything other than a number in mapsize gives the same output, ~ equivalent to entering 500. — kwami (talk) 06:25, 10 January 2023 (UTC)Reply
I've changed the infobox, checking articles. No problems so far. — kwami (talk) 06:26, 10 January 2023 (UTC)Reply
I don't see how |upright= has any effect on anything. — kwami (talk) 06:29, 10 January 2023 (UTC)Reply
@Kwamikagami: Have you tried changing your preference for thumbnail size away from 220px? — hike395 (talk) 07:09, 10 January 2023 (UTC)Reply
No, but I would think that setting upright=2 would be visible regardless. — kwami (talk) 07:11, 10 January 2023 (UTC)Reply
Oh, I bet I know what this is. This is a limitation in MediaWiki. If you start with a tiny image, it won't blow it up larger than its actual size. What's the example of upright not working? — hike395 (talk) 07:14, 10 January 2023 (UTC)Reply
I see that at e.g. Malay language, where the map is an SVG but the nominal size is only 257×190px. And indeed, the English map has a nominal size of 512×260px, which is probably what I was getting when I set the size to anything but a number. But the map at Arabic language is nominally 1200px, and 'upright' has no effect there either (neither map nor image). — kwami (talk) 07:20, 10 January 2023 (UTC)Reply
I'm a bit confused. File:Arabic albayancalligraphy.svg (the example image in the infobox) is 343px, so it won't get bigger than that. File:Arabic speaking world.svg is 1200px, but |upright= appears to work (see below). — hike395 (talk) 07:30, 10 January 2023 (UTC)Reply
Yeah, looks fine here, but no effect in the infobox. I just saved a test edit on that page, in case the preview wasn't working: nothing. — kwami (talk) 07:37, 10 January 2023 (UTC)Reply

   

I think there was a misunderstanding. I didn't implement |upright= in {{Infobox language}}: I just made the default have scalable thumbnails. In Template:Infobox language/sandbox I implemented |imageupright= and |mapupright= to work as you would think, see Template:Infobox language/testcases#Test upright for the results. — hike395 (talk) 09:43, 10 January 2023 (UTC)Reply
Ah, thank you. Yes, that works beautifully.
I changed the labels to 'imagescale' and 'mapscale', as there's been some confusion that 'upright' is only used will tall images. — kwami (talk) 10:39, 10 January 2023 (UTC)Reply

Updated strip marker edit

According to mw:Strip marker, the code for strip markers has changed. You need to replicate this change in order to get that code to work again. Strainu (talk) 20:58, 20 November 2023 (UTC)Reply

Implemented in the Module:InfoboxImage/sandbox, but none of the existing tests failed. What is this change supposed to accomplish? Is there a test case where the old code fails and the new one succeeds? — hike395 (talk) 01:15, 21 November 2023 (UTC)Reply
Yes, the change is supposed to allow {{Multiple images}} to be used with InfoboxImage: see the infobox at ro:Târgoviște. From what I can see, Template:Multiple images has the same implementation as on rowiki, so it's very likely to fail with the old implementation. Strainu (talk) 08:11, 21 November 2023 (UTC)Reply
Lines 178-180 already handle the updated format. It's just that lines 175-178 were not updated previously. -- WOSlinker (talk) 09:31, 21 November 2023 (UTC)Reply
Is it safe to simply delete lines 175-177? — hike395 (talk) 12:32, 21 November 2023 (UTC)Reply
Either would work, so I've applied the sandbox change and removed the other check. -- WOSlinker (talk) 13:27, 21 November 2023 (UTC)Reply
Added a test case using {{Multiple images}} (although it was not failing previously). — hike395 (talk) 19:42, 21 November 2023 (UTC)Reply

Explicit option to not add image edit

This module is sometimes called by an infobox which passes on an image parameter if it's given in the call and otherwise automatically passes on a Wikidata image. If an article explicitly wants no image then it can pick one of the suppressed image names like image=No image available.png in [1] which uses {{Infobox dam}}. That was hard to work out, later editors of the article may blank the bad looking image parameter in good faith, and I don't know whether the list of suppressed images is certain to never remove a listed image name. I suggest adding a clear and simple value |image=no to not display any image. A blank |image= already does this but as mentioned, that doesn't work in some calls of infoboxes. I came here after working on Wikipedia:Teahouse#Technical question about infobox. PrimeHunter (talk) 12:09, 1 December 2023 (UTC)Reply

Should all instances of a nested {{Infobox dam}} disable the image? If so, the fix is straightforward in that template. Gonnym (talk) 12:21, 1 December 2023 (UTC)Reply