Module:InfoboxImage: Difference between revisions
From Roses, Tulips, & Liberty
Content added Content deleted
No edit summary |
No edit summary |
||
Line 38: | Line 38: | ||
function i.IsPlaceholder(image) |
function i.IsPlaceholder(image) |
||
-- change underscores to spaces |
|||
image2 = mw.ustring.gsub(image, "_", " ") |
image2 = mw.ustring.gsub(image, "_", " ") |
||
-- if image starts with [[ then remove that and anything after | |
|||
if mw.ustring.sub(image2,1,2) == "[[" then |
|||
image2 = mw.ustring.sub(image2,3) |
|||
image2 = mw.ustring.gsub(image2, "([^|]*)|.*", "%1") |
|||
end |
|||
-- remove file: or image: prefix if exists |
|||
if mw.ustring.lower(mw.ustring.sub(image2,1,5)) == "file:" then |
|||
image2 = mw.ustring.sub(image2,6,mw.ustring.len(image2)); |
|||
end |
|||
if mw.ustring.lower(mw.ustring.sub(image2,1,6)) == "image:" then |
|||
image2 = mw.ustring.sub(image2,7,mw.ustring.len(image2)); |
|||
end |
|||
-- capitalise first letter |
|||
image2 = mw.ustring.upper(mw.ustring.sub(image2,1,1)) .. mw.ustring.sub(image2,2) |
image2 = mw.ustring.upper(mw.ustring.sub(image2,1,1)) .. mw.ustring.sub(image2,2) |
||
Line 59: | Line 73: | ||
end |
end |
||
if |
if mw.ustring.sub(image,1,2) == "[[" then |
||
return image; |
return image; |
||
else |
else |
||
Line 68: | Line 82: | ||
-- remove file: or image: prefix if exists |
-- remove file: or image: prefix if exists |
||
if |
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then |
||
image = |
image = mw.ustring.sub(image,6,mw.ustring.len(image)); |
||
end |
end |
||
if |
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then |
||
image = |
image = mw.ustring.sub(image,7,mw.ustring.len(image)); |
||
end |
end |
||