Module:InfoboxImage: Difference between revisions
From Test Wiki
Content deleted Content added
m 1 revision imported |
Created page with "-- Inputs: -- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link -- size - size to display the image -- m..." |
||
Line 1:
-- Inputs:
-- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link
-- size - size to display the image
-- maxsize - maximum size for image
-- sizedefault - default size to display the image if size param is blank
-- alt - alt text for image
-- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it
-- Outputs:
-- Formatted image.
Line 44 ⟶ 38:
"Silver - Replace this image female.svg",
"Silver - Replace this image male.svg",
}
Line 93 ⟶ 43:
-- change underscores to spaces
image = mw.ustring.gsub(image, "_", " ");
-- if image starts with [[ then remove that and anything after |
if mw.ustring.sub(image,1,2) == "[[" then
image = mw.ustring.sub(image,3);
image = mw.ustring.gsub(image, "([^|]*)|.*", "%1");
end
-- Trim spaces
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
-- remove file: or image: prefix if exists
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then
end
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then
image = mw.ustring.sub(image,7);
end
-- Trim spaces
Line 135 ⟶ 79:
return image;
end
if frame.args["suppressplaceholder"]
if i.IsPlaceholder(image) == true then
return "";
Line 164 ⟶ 108:
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]]";
else
return image;
Line 174 ⟶ 116:
return image;
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;
else
local result = "";
local size = frame.args["size"];
local maxsize = frame.args["maxsize"];
local sizedefault = frame.args["sizedefault"];
local alt = frame.args["alt"];
local border = frame.args["border"];
-- remove file: or image: prefix if exists
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then
end
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then
end
Line 212 ⟶ 142:
if size ~= "" and size ~= nil then
local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0;
local maxsizenumber = tonumber(mw.ustring.match(maxsize,"%d*"))
if sizenumber>maxsizenumber and maxsizenumber>0 then
size = maxsize;
Line 221 ⟶ 151:
if (tonumber(size) or 0) > 0 then
size = size .. "px";
end
result = "[[File:" .. image;
if size ~= "" and size ~= nil then
result = result .. "|" .. size;
Line 237 ⟶ 160:
else
result = result .. "|frameless";
end
if alt ~= "" and alt ~= nil then
result = result .. "|alt=" .. alt;
end
if border == "yes" then
result = result .. "|border";
end
result = result .. "]]";
| |||