Module:InfoboxImage

-- 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-- title - title text for image-- border - set to yes if border-- center - set to yes, if the image has to be centered-- upright - upright image param-- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it-- Outputs:-- Formatted image.-- More details available at the "Module:InfoboxImage/doc" pagelocali={};localplaceholder_image={"Blue - Replace this image female.svg","Blue - Replace this image male.svg","Female no free image yet.png","Flag of None (square).svg","Flag of None.svg","Flag of.svg","Green - Replace this image female.svg","Green - Replace this image male.svg","Image is needed female.svg","Image is needed male.svg","Location map of None.svg","Male no free image yet.png","Missing flag.png","No flag.svg","No free portrait.svg","No portrait (female).svg","No portrait (male).svg","Red - Replace this image female.svg","Red - Replace this image male.svg","Replace this image female (blue).svg","Replace this image female.svg","Replace this image male (blue).svg","Replace this image male.svg","Silver - Replace this image female.svg","Silver - Replace this image male.svg",}functioni.IsPlaceholder(image)-- change underscores to spacesimage=mw.ustring.gsub(image,"_"," ");-- if image starts with [[ then remove that and anything after |ifmw.ustring.sub(image,1,2)=="[["thenimage=mw.ustring.sub(image,3);image=mw.ustring.gsub(image,"([^|]*)|.*","%1");end-- Trim spacesimage=mw.ustring.gsub(image,'^[ ]*(.-)[ ]*$','%1');-- remove file: or image: prefix if existsifmw.ustring.lower(mw.ustring.sub(image,1,5))=="file:"thenimage=mw.ustring.sub(image,6);endifmw.ustring.lower(mw.ustring.sub(image,1,6))=="image:"thenimage=mw.ustring.sub(image,7);end-- Trim spacesimage=mw.ustring.gsub(image,'^[ ]*(.-)[ ]*$','%1');-- capitalise first letterimage=mw.ustring.upper(mw.ustring.sub(image,1,1))..mw.ustring.sub(image,2);fori,jinpairs(placeholder_image)doifimage==jthenreturntrueendendreturnfalseendfunctioni.InfoboxImage(frame)localimage=frame.args["image"];ifimage==""orimage==nilthenreturn"";endifimage=="&nbsp;"thenreturnimage;endifframe.args["suppressplaceholder"]=="yes"thenifi.IsPlaceholder(image)==truethenreturn"";endendifmw.ustring.lower(mw.ustring.sub(image,1,5))=="http:"thenreturn"";endifmw.ustring.lower(mw.ustring.sub(image,1,6))=="[http:"thenreturn"";endifmw.ustring.lower(mw.ustring.sub(image,1,7))=="[[http:"thenreturn"";endifmw.ustring.lower(mw.ustring.sub(image,1,6))=="https:"thenreturn"";endifmw.ustring.lower(mw.ustring.sub(image,1,7))=="[https:"thenreturn"";endifmw.ustring.lower(mw.ustring.sub(image,1,8))=="[[https:"thenreturn"";endifmw.ustring.sub(image,1,2)=="[["then-- search for thumbnail images and add to tracking cat if foundifmw.title.getCurrentTitle().namespace==0and(mw.ustring.find(image,"|%s*thumb%s*[|%]]")ormw.ustring.find(image,"|%s*thumbnail%s*[|%]]"))thenreturnimage.."[[Category:Pages using infoboxes with thumbnail images]]";elsereturnimage;endelseifmw.ustring.sub(image,1,2)=="{{"andmw.ustring.sub(image,1,3)~="{{{"thenreturnimage;elseifmw.ustring.sub(image,1,1)=="<"thenreturnimage;elseifmw.ustring.sub(image,1,5)==mw.ustring.char(127).."UNIQ"then-- Found strip marker at begining, so pass don't process at allreturnimage;elselocalresult="";localsize=frame.args["size"];localmaxsize=frame.args["maxsize"];localsizedefault=frame.args["sizedefault"];localalt=frame.args["alt"];localtitle=frame.args["title"];localborder=frame.args["border"];localupright=frame.args["upright"]or"";localcenter=frame.args["center"];-- remove file: or image: prefix if existsifmw.ustring.lower(mw.ustring.sub(image,1,5))=="file:"thenimage=mw.ustring.sub(image,6);endifmw.ustring.lower(mw.ustring.sub(image,1,6))=="image:"thenimage=mw.ustring.sub(image,7);endifmaxsize~=""andmaxsize~=nilthen-- if no sizedefault then set to maxsizeifsizedefault==""orsizedefault==nilthensizedefault=maxsizeend-- check to see if size bigger than maxsizeifsize~=""andsize~=nilthenlocalsizenumber=tonumber(mw.ustring.match(size,"%d*"))or0;localmaxsizenumber=tonumber(mw.ustring.match(maxsize,"%d*"));ifsizenumber>maxsizenumberandmaxsizenumber>0thensize=maxsize;endendend-- add px to size if just a numberif(tonumber(size)or0)>0thensize=size.."px";endresult="[[File:"..image;ifsize~=""andsize~=nilthenresult=result.."|"..size;elseifsizedefault~=""andsizedefault~=nilthenresult=result.."|"..sizedefault;elseresult=result.."|frameless";endifcenter=="yes"thenresult=result.."|center"endifalt~=""andalt~=nilthenresult=result.."|alt="..alt;endifborder=="yes"thenresult=result.."|border";endifupright~=""thenresult=result.."|upright="..upright;endiftitle~=""andtitle~=nilthenresult=result.."|"..title;elseifalt~=""andalt~=nilthenresult=result.."|"..alt;endresult=result.."]]";returnresult;endendreturni;