Module:InfoboxImage: Difference between revisions

From Roses, Tulips, & Liberty
Content added Content deleted
(per talk and WP:IPH, consensus is to standard exclude)
(change as per request by User:Nullzero to make file & image prefixes work with other languages)
Line 55: Line 55:
-- Trim spaces
-- Trim spaces
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1');
-- remove file: or image: prefix if exists
-- remove prefix if exists
local allNames = mw.site.namespaces[6].aliases
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then
image = mw.ustring.sub(image,6);
allNames[#allNames + 1] = mw.site.namespaces[6].name
allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName
end
for i, name in ipairs(allNames) do
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then
image = mw.ustring.sub(image,7);
if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then
image = mw.ustring.sub(image, mw.ustring.len(name) + 2);
break
end
end
end
-- Trim spaces
-- Trim spaces
Line 136: Line 139:
local center= frame.args["center"];
local center= frame.args["center"];
-- remove file: or image: prefix if exists
-- remove prefix if exists
local allNames = mw.site.namespaces[6].aliases
if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "file:" then
image = mw.ustring.sub(image,6);
allNames[#allNames + 1] = mw.site.namespaces[6].name
allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName
end
for i, name in ipairs(allNames) do
if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "image:" then
image = mw.ustring.sub(image,7);
if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then
image = mw.ustring.sub(image, mw.ustring.len(name) + 2);
break
end
end
end