<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://cherry-pi.tailb1a250.ts.net/index.php?action=history&amp;feed=atom&amp;title=Module%3AInfoboxLua%2FImageResolver</id>
	<title>Module:InfoboxLua/ImageResolver - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://cherry-pi.tailb1a250.ts.net/index.php?action=history&amp;feed=atom&amp;title=Module%3AInfoboxLua%2FImageResolver"/>
	<link rel="alternate" type="text/html" href="https://cherry-pi.tailb1a250.ts.net/index.php?title=Module:InfoboxLua/ImageResolver&amp;action=history"/>
	<updated>2026-11-11T05:37:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://cherry-pi.tailb1a250.ts.net/index.php?title=Module:InfoboxLua/ImageResolver&amp;diff=489&amp;oldid=prev</id>
		<title>Gravy: Created page with &quot;require(&#039;strict&#039;)  local p = {}  -- Extensions probed for an auto-discovered infobox image, in priority order. -- WebP first (house format), then the common screenshot formats. The gadget -- normalises a .jpeg upload to a .jpg name, so .jpeg is not probed. local PROBE_EXTENSIONS = { &#039;webp&#039;, &#039;png&#039;, &#039;jpg&#039; }  --- The conventional filename base for a page&#039;s quick-uploaded infobox image. --- e.g. &#039;Gladius&#039; -&gt; &#039;Gladius - infobox&#039;. --- @param pageTitle string The namespace-less...&quot;</title>
		<link rel="alternate" type="text/html" href="https://cherry-pi.tailb1a250.ts.net/index.php?title=Module:InfoboxLua/ImageResolver&amp;diff=489&amp;oldid=prev"/>
		<updated>2026-11-11T04:54:59Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;require(&amp;#039;strict&amp;#039;)  local p = {}  -- Extensions probed for an auto-discovered infobox image, in priority order. -- WebP first (house format), then the common screenshot formats. The gadget -- normalises a .jpeg upload to a .jpg name, so .jpeg is not probed. local PROBE_EXTENSIONS = { &amp;#039;webp&amp;#039;, &amp;#039;png&amp;#039;, &amp;#039;jpg&amp;#039; }  --- The conventional filename base for a page&amp;#039;s quick-uploaded infobox image. --- e.g. &amp;#039;Gladius&amp;#039; -&amp;gt; &amp;#039;Gladius - infobox&amp;#039;. --- @param pageTitle string The namespace-less...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Extensions probed for an auto-discovered infobox image, in priority order.&lt;br /&gt;
-- WebP first (house format), then the common screenshot formats. The gadget&lt;br /&gt;
-- normalises a .jpeg upload to a .jpg name, so .jpeg is not probed.&lt;br /&gt;
local PROBE_EXTENSIONS = { &amp;#039;webp&amp;#039;, &amp;#039;png&amp;#039;, &amp;#039;jpg&amp;#039; }&lt;br /&gt;
&lt;br /&gt;
--- The conventional filename base for a page&amp;#039;s quick-uploaded infobox image.&lt;br /&gt;
--- e.g. &amp;#039;Gladius&amp;#039; -&amp;gt; &amp;#039;Gladius - infobox&amp;#039;.&lt;br /&gt;
--- @param pageTitle string The namespace-less page title.&lt;br /&gt;
--- @return string&lt;br /&gt;
function p.conventionBase(pageTitle)&lt;br /&gt;
	return pageTitle .. &amp;#039; - infobox&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Default file-existence oracle: true when File:&amp;lt;filename&amp;gt; exists as media.&lt;br /&gt;
--- Expensive (file lookup on a non-current title); only reached in production.&lt;br /&gt;
--- @param filename string A filename WITH extension, e.g. &amp;#039;Gladius - infobox.png&amp;#039;.&lt;br /&gt;
--- @return boolean&lt;br /&gt;
local function defaultFileExists(filename)&lt;br /&gt;
	local title = mw.title.makeTitle(&amp;#039;File&amp;#039;, filename)&lt;br /&gt;
	return title ~= nil and title.file ~= nil and title.file.exists == true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Resolve the auto-discovered infobox image for a convention base.&lt;br /&gt;
--- Probes &amp;#039;&amp;lt;base&amp;gt;.&amp;lt;ext&amp;gt;&amp;#039; for each ext in PROBE_EXTENSIONS, short-circuiting on&lt;br /&gt;
--- the first hit. Returns the full filename (with extension) or nil.&lt;br /&gt;
--- @param base string The convention base, e.g. &amp;#039;Gladius - infobox&amp;#039;.&lt;br /&gt;
--- @param opts { fileExists: fun(filename: string): boolean }|nil Injectable oracle (tests).&lt;br /&gt;
--- @return string|nil&lt;br /&gt;
function p.resolveDiscoveredSrc(base, opts)&lt;br /&gt;
	local fileExists = (opts and opts.fileExists) or defaultFileExists&lt;br /&gt;
	for _, ext in ipairs(PROBE_EXTENSIONS) do&lt;br /&gt;
		local filename = base .. &amp;#039;.&amp;#039; .. ext&lt;br /&gt;
		if fileExists(filename) then&lt;br /&gt;
			return filename&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Exposed for tests / callers that want the probe order.&lt;br /&gt;
p.PROBE_EXTENSIONS = PROBE_EXTENSIONS&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Gravy</name></author>
	</entry>
</feed>