Módulo:Clean image
Ir para navegação
Ir para pesquisar
Documentação do módulo
Esta documentação é transcluída de Predefinição:Sem documentação/doc. [editar] [atualizar]
Este módulo não possui nenhuma documentação. Por favor, considere adicionar uma documentação em Módulo:Clean image/doc. [editar]
Módulo:Clean image's a função main é invocada por Predefinição:Clean image.
Módulo:Clean image requer Module:Paramtest.
Módulo:Clean image é solicitado por Módulo:Databox Pet.
Módulo:Clean image é solicitado por Módulo:Infobox Skin.
Módulo:Clean image é solicitado por Módulo:Infobox non-player character.
Módulo:Clean image é solicitado por Módulo:Infobox scenery.
-- Removes 'File:' prefix, just in case
-- Replace {{!}} with | instead of preprocessing
-- Turn into a nice wiki file link
local hc = require('Module:Paramtest').has_content
local p = {}
p.main = function(frame)
local args = frame:getParent().args
local clean = {
file = args.file or args[1],
width = args.width or args[2],
height = args.height or args[3],
link = args.link
}
return p.clean(clean)
end
p.clean = function(args)
local file = args.file
if not hc(file) or (file and (file:lower() == 'no' or file:lower() == 'não' or file == '')) then
return ''
end
local height, width = '',''
if hc(args.height) then
height = 'x'..args.height
end
if hc(args.width) then
width = args.width
end
local link = ''
if hc(args.link) then
if args.link == 'no' then
link = '|link='
else
link = '|link='..args.link
end
end
local size = ''
if width ~= '' or height ~= '' then
size = string.format('|%s%spx', width, height)
end
file = file:gsub('%[',''):gsub('%]',''):gsub('[Aa]rquivo:',''):gsub('[Ff]icheiro:',''):gsub('[Ff]ile:',''):gsub('{{!}}','|')
-- enforce max height and width
file = mw.text.split(file, '|')
file = string.format('%s%s%s',file[1], size, link)
return '[[Arquivo:'..file..'|frameless]]'
end
return p