Editing Module:InfoboxImage
Appearance
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 12: | Line 12: | ||
-- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it | -- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it | ||
-- link - page to visit when clicking on image | -- link - page to visit when clicking on image | ||
-- Outputs: | -- Outputs: | ||
-- Formatted image. | -- Formatted image. | ||
Line 22: | Line 21: | ||
"Blue - Replace this image female.svg", | "Blue - Replace this image female.svg", | ||
"Blue - Replace this image male.svg", | "Blue - Replace this image male.svg", | ||
"Female no free image yet.png", | |||
"Flag of None (square).svg", | "Flag of None (square).svg", | ||
"Flag of None.svg", | "Flag of None.svg", | ||
Line 38: | Line 38: | ||
"Red - Replace this image female.svg", | "Red - Replace this image female.svg", | ||
"Red - Replace this image male.svg", | "Red - Replace this image male.svg", | ||
"Replace this image female (blue).svg", | |||
"Replace this image female.svg", | "Replace this image female.svg", | ||
"Replace this image male (blue).svg", | "Replace this image male (blue).svg", | ||
Line 87: | Line 88: | ||
"Project Trains no image.png", | "Project Trains no image.png", | ||
"Image-request.png", | "Image-request.png", | ||
} | } | ||
function i.IsPlaceholder(image) | function i.IsPlaceholder(image) | ||
Line 134: | Line 124: | ||
end | end | ||
return false | return false | ||
end | end | ||
Line 143: | Line 129: | ||
local image = frame.args["image"]; | local image = frame.args["image"]; | ||
if | if image == "" or image == nil then | ||
return ""; | return ""; | ||
end | end | ||
Line 154: | Line 140: | ||
end | end | ||
end | end | ||
if | 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 | |||
if mw.ustring.sub(image,1,2) == "[[" then | if mw.ustring.sub(image,1,2) == "[[" then | ||
-- search for thumbnail images and add to tracking cat if found | -- search for thumbnail images and add to tracking cat if found | ||
if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then | if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then | ||
return image .. "[[Category:Pages using infoboxes with thumbnail images]]"; | |||
elseif mw.title.getCurrentTitle().namespace == 0 then | |||
return image .. "[[Category:Pages using deprecated image syntax]]"; | |||
else | |||
return image; | |||
end | end | ||
elseif mw.ustring.sub(image,1,2) == "{{" and mw.ustring.sub(image,1,3) ~= "{{{" then | elseif mw.ustring.sub(image,1,2) == "{{" and mw.ustring.sub(image,1,3) ~= "{{{" then | ||
return image; | return image; | ||
elseif mw.ustring.sub(image,1,1) == "<" then | elseif mw.ustring.sub(image,1,1) == "<" then | ||
return image; | return image; | ||
elseif mw.ustring.sub(image,1, | elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then | ||
-- Found strip marker at begining, so pass don't process at all | |||
return image; | |||
elseif mw.ustring.sub(image,4,9) == "`UNIQ-" then | |||
-- Found strip marker at begining, so pass don't process at all | -- Found strip marker at begining, so pass don't process at all | ||
return image; | return image; | ||
Line 177: | Line 182: | ||
local result = ""; | local result = ""; | ||
local page = frame.args["page"]; | local page = frame.args["page"]; | ||
local size = frame.args["size"]; | local size = frame.args["size"]; | ||
local maxsize = frame.args["maxsize"]; | local maxsize = frame.args["maxsize"]; | ||
Line 185: | Line 189: | ||
local title = frame.args["title"]; | local title = frame.args["title"]; | ||
local border = frame.args["border"]; | local border = frame.args["border"]; | ||
local upright = frame.args["upright"] or ""; | |||
local thumbtime = frame.args["thumbtime"] or ""; | local thumbtime = frame.args["thumbtime"] or ""; | ||
local center = frame.args["center | local center= frame.args["center"]; | ||
-- remove prefix if exists | -- remove prefix if exists | ||
Line 200: | Line 204: | ||
end | end | ||
if | if maxsize ~= "" and maxsize ~= nil then | ||
-- if no sizedefault | -- if no sizedefault then set to maxsize | ||
if | if sizedefault == "" or sizedefault == nil then | ||
sizedefault = maxsize | sizedefault = maxsize | ||
end | end | ||
-- check to see if size bigger than maxsize | -- check to see if size bigger than maxsize | ||
if size ~= "" and size ~= nil then | |||
local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0; | local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0; | ||
if sizenumber > maxsizenumber and maxsizenumber > 0 then | local maxsizenumber = tonumber(mw.ustring.match(maxsize,"%d*")) or 0; | ||
if sizenumber>maxsizenumber and maxsizenumber>0 then | |||
size = maxsize; | size = maxsize; | ||
end | end | ||
end | end | ||
Line 231: | Line 228: | ||
result = "[[File:" .. image; | result = "[[File:" .. image; | ||
if | if page ~= "" and page ~= nil then | ||
result = result .. "|page=" .. page; | result = result .. "|page=" .. page; | ||
end | end | ||
if | if size ~= "" and size ~= nil then | ||
result = result .. "|" .. size; | result = result .. "|" .. size; | ||
elseif | elseif sizedefault ~= "" and sizedefault ~= nil then | ||
result = result .. "|" .. sizedefault; | result = result .. "|" .. sizedefault; | ||
else | else | ||
Line 244: | Line 241: | ||
result = result .. "|center" | result = result .. "|center" | ||
end | end | ||
if | if alt ~= "" and alt ~= nil then | ||
result = result .. "|alt=" .. alt; | result = result .. "|alt=" .. alt; | ||
end | end | ||
if | if link ~= "" and link ~= nil then | ||
result = result .. "|link=" .. link; | result = result .. "|link=" .. link; | ||
end | end | ||
Line 261: | Line 258: | ||
result = result .. "|thumbtime=" .. thumbtime; | result = result .. "|thumbtime=" .. thumbtime; | ||
end | end | ||
if | if title ~= "" and title ~= nil then | ||
result = result .. "|" .. title; | result = result .. "|" .. title; | ||
elseif alt ~= "" and alt ~= nil then | |||
result = result .. "|" .. alt; | |||
end | end | ||
result = result .. "]]"; | result = result .. "]]"; |