缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!
该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!
全站通知:
模块:图
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:图/doc创建
-- Module:图
local p = {}
local fstr = mw.ustring.format -- shortcut for formattig a string
local getArgs = require('Module:Dev/Arguments').getArgs
local yesno = require('Module:Dev/Yesno')
local utils = require([[Module:Utils]])
local function endswith(s, suffix) end
-- test by: = p._main({"12", "sampleImage"})
-- test by: = p._main({"12", "sampleImage", "alt link"})
-- test by: = p._main({"12", "sampleImage", "alt link", "alt text"})
-- test by: = p._main({"12", "sampleImage", "alt link", "alt text", text="1"})
-- test by: = p._main({"12", "sampleImage", "alt link", "alt text", text="1", nowrap="1"})
-- test by: = p._main({"12", "sampleImage", "alt link", "alt text", rotate="180"})
-- test by: = p._main({"12", "sampleImage", "alt link", "alt text", ['use height']="1"})
function p._main(args)
local dim = args[1]
if not utils.endswith(dim, "px") then dim = dim .. "px" end
if args['use height'] then
if not utils.endswith(dim, "x") then dim = 'x' .. dim end
end
local link = args[3] or args[2]
local altText = args[4] or link
local out = mw.html.create('span')
out:addClass('t-pic')
out:addClass(args.class)
local rotate = args.rotate and tonumber(args.rotate) or 0
if rotate ~= 0 then out:css('transform', fstr('rotate(%ddeg)', rotate)) end
out:wikitext(fstr('[[File:%s.png|%s|link=%s|%s]]', args[2], dim, link,
altText))
out = tostring(out)
if yesno(args.text) then
out = fstr("%s [[%s|%s]]", out, link, altText)
end
if yesno(args.text)and yesno(args.nowrap) then
out = fstr("<span style='white-space: nowrap'>%s</span>", out)
end
return out
end
function p.main(frame) return p._main(getArgs(frame)) end
return p