https://wiki.casperdns.com/index.php?title=Module:InfoboxImage&feed=atom&action=history
Module:InfoboxImage - Revision history
2024-03-28T12:14:03Z
Revision history for this page on the wiki
MediaWiki 1.35.0
https://wiki.casperdns.com/index.php?title=Module:InfoboxImage&diff=1521&oldid=prev
D1cd5b71-6209-4595-9bf0-771bf689ce00: 1 revision
2013-06-28T12:19:46Z
<p>1 revision</p>
<p><b>New page</b></p><div>-- Inputs:<br />
-- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link<br />
-- size - size to display the image<br />
-- maxsize - maximum size for image<br />
-- sizedefault - default size to display the image if size param is blank<br />
-- alt - alt text for image<br />
-- title - title text for image<br />
-- border - set to yes if border<br />
-- center - set to yes, if the image has to be centered<br />
-- upright - upright image param<br />
-- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it<br />
-- Outputs:<br />
-- Formatted image.<br />
-- More details available at the "Module:InfoboxImage/doc" page<br />
<br />
local i = {};<br />
<br />
local placeholder_image = {<br />
"Blue - Replace this image female.svg",<br />
"Blue - Replace this image male.svg",<br />
"Female no free image yet.png",<br />
"Flag of None (square).svg",<br />
"Flag of None.svg",<br />
"Flag of.svg",<br />
"Green - Replace this image female.svg",<br />
"Green - Replace this image male.svg",<br />
"Image is needed female.svg",<br />
"Image is needed male.svg",<br />
"Location map of None.svg",<br />
"Male no free image yet.png",<br />
"Missing flag.png",<br />
"No flag.svg",<br />
"No free portrait.svg",<br />
"No portrait (female).svg",<br />
"No portrait (male).svg",<br />
"Red - Replace this image female.svg",<br />
"Red - Replace this image male.svg",<br />
"Replace this image female (blue).svg",<br />
"Replace this image female.svg",<br />
"Replace this image male (blue).svg",<br />
"Replace this image male.svg",<br />
"Silver - Replace this image female.svg",<br />
"Silver - Replace this image male.svg",<br />
}<br />
<br />
function i.IsPlaceholder(image)<br />
-- change underscores to spaces<br />
image = mw.ustring.gsub(image, "_", " ");<br />
-- if image starts with [[ then remove that and anything after |<br />
if mw.ustring.sub(image,1,2) == "[[" then<br />
image = mw.ustring.sub(image,3);<br />
image = mw.ustring.gsub(image, "([^|]*)|.*", "%1");<br />
end<br />
-- Trim spaces<br />
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');<br />
-- remove file: or image: prefix if exists<br />
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then<br />
image = mw.ustring.sub(image,6);<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then<br />
image = mw.ustring.sub(image,7);<br />
end<br />
-- Trim spaces<br />
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');<br />
-- capitalise first letter<br />
image = mw.ustring.upper(mw.ustring.sub(image,1,1)) .. mw.ustring.sub(image,2);<br />
<br />
for i,j in pairs(placeholder_image) do<br />
if image == j then<br />
return true<br />
end<br />
end<br />
return false<br />
end<br />
<br />
function i.InfoboxImage(frame)<br />
local image = frame.args["image"];<br />
<br />
if image == "" or image == nil then<br />
return "";<br />
end<br />
if image == "&nbsp;" then<br />
return image;<br />
end<br />
if frame.args["suppressplaceholder"] == "yes" then<br />
if i.IsPlaceholder(image) == true then<br />
return "";<br />
end<br />
end<br />
<br />
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "http:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "[http:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[[http:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "https:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[https:" then<br />
return "";<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,8)) == "[[https:" then<br />
return "";<br />
end<br />
<br />
if mw.ustring.sub(image,1,2) == "[[" then<br />
-- search for thumbnail images and add to tracking cat if found<br />
if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then<br />
return image .. "[[Category:Pages using infoboxes with thumbnail images]]";<br />
else<br />
return image;<br />
end<br />
elseif mw.ustring.sub(image,1,2) == "{{" and mw.ustring.sub(image,1,3) ~= "{{{" then<br />
return image;<br />
elseif mw.ustring.sub(image,1,1) == "<" then<br />
return image;<br />
elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then<br />
-- Found strip marker at begining, so pass don't process at all<br />
return image;<br />
else<br />
local result = "";<br />
local size = frame.args["size"];<br />
local maxsize = frame.args["maxsize"];<br />
local sizedefault = frame.args["sizedefault"];<br />
local alt = frame.args["alt"];<br />
local title = frame.args["title"];<br />
local border = frame.args["border"];<br />
local upright = frame.args["upright"] or "";<br />
local center= frame.args["center"];<br />
<br />
-- remove file: or image: prefix if exists<br />
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then<br />
image = mw.ustring.sub(image,6);<br />
end<br />
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then<br />
image = mw.ustring.sub(image,7);<br />
end<br />
<br />
if maxsize ~= "" and maxsize ~= nil then<br />
-- if no sizedefault then set to maxsize<br />
if sizedefault == "" or sizedefault == nil then<br />
sizedefault = maxsize<br />
end<br />
-- check to see if size bigger than maxsize<br />
if size ~= "" and size ~= nil then<br />
local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0;<br />
local maxsizenumber = tonumber(mw.ustring.match(maxsize,"%d*"));<br />
if sizenumber>maxsizenumber and maxsizenumber>0 then<br />
size = maxsize;<br />
end<br />
end<br />
end<br />
-- add px to size if just a number<br />
if (tonumber(size) or 0) > 0 then<br />
size = size .. "px";<br />
end<br />
<br />
result = "[[File:" .. image;<br />
if size ~= "" and size ~= nil then<br />
result = result .. "|" .. size;<br />
elseif sizedefault ~= "" and sizedefault ~= nil then<br />
result = result .. "|" .. sizedefault;<br />
else<br />
result = result .. "|frameless";<br />
end<br />
if center == "yes" then<br />
result = result .. "|center"<br />
end<br />
if alt ~= "" and alt ~= nil then<br />
result = result .. "|alt=" .. alt;<br />
end<br />
if border == "yes" then<br />
result = result .. "|border";<br />
end<br />
if upright ~= "" then<br />
result = result .. "|upright=" .. upright;<br />
end<br />
if title ~= "" and title ~= nil then<br />
result = result .. "|" .. title;<br />
elseif alt ~= "" and alt ~= nil then<br />
result = result .. "|" .. alt;<br />
end<br />
result = result .. "]]";<br />
<br />
return result;<br />
end<br />
end<br />
<br />
return i;</div>
D1cd5b71-6209-4595-9bf0-771bf689ce00