Module:InfoboxImage: Difference between revisions
From Vigyanwiki
Template>WOSlinker No edit summary |
Template>WOSlinker No edit summary |
||
Line 29: | Line 29: | ||
result = "[[File:" .. frame.args["image"]; | result = "[[File:" .. frame.args["image"]; | ||
result = result .. "|" .. | if size ~= "" and size ~= nil then | ||
result = result .. "|" .. size; | |||
elseif sizedefault ~= "" and sizedefault ~= nil then | |||
result = result .. "|" .. sizedefault; | |||
else | |||
result = result .. "|frameless"; | |||
end | |||
if alt ~= "" and alt ~= nil then | if alt ~= "" and alt ~= nil then | ||
result = result .. "|alt=" .. alt; | result = result .. "|alt=" .. alt; |
Revision as of 18:36, 4 September 2012
Documentation for this module may be created at Module:InfoboxImage/doc
-- Inputs:
-- image - Can either be a bare filename or a fully formatted image link
-- size - size to display the image
-- sizedefault - default size to display the image if size param is blank
-- alt - alt text for image
-- Outputs:
-- Formatted image.
local i = {};
function i.InfoboxImage(frame)
local image = frame.args["image"];
if image == "" or image == nil then
return ""
end
if string.sub(frame.args["image"],1,2) == "[[" then
return frame.args["image"];
else
local result = "";
local size = frame.args["size"];
local sizedefault = frame.args["sizedefault"];
local alt = frame.args["alt"];
if (tonumber(size) or 0) > 0 then
size = size .. "px";
end
result = "[[File:" .. frame.args["image"];
if size ~= "" and size ~= nil then
result = result .. "|" .. size;
elseif sizedefault ~= "" and sizedefault ~= nil then
result = result .. "|" .. sizedefault;
else
result = result .. "|frameless";
end
if alt ~= "" and alt ~= nil then
result = result .. "|alt=" .. alt;
end
result = result .. "]]";
return result;
end
end
return i;