Module:Random image
可在Module:Random image/doc创建此模块的帮助文档
local p = {}
local pagename_escape={
["#"]="#",
["<"]="<",
[">"]=">",
["["]="[",
["]"]="]",
["|"]="|",
["{"]="{",
["}"]="}",
}
function SpecialPageName(pagename)
-- 请在这里添加页面名转换
-- 当页面名和title_localized:en的值不同时,请在这里转换
pagename=string.gsub(pagename,"[#<>%[%]|{}]",pagename_escape)
return pagename
end
function p.image(frame)
local data = mw.getCurrentFrame():expandTemplate{ title = 'Songlist' }
local result=mw.text.jsonDecode( data )
local id=result['songs'][tonumber(frame.args.number)]['id']
local title=SpecialPageName(result['songs'][tonumber(frame.args.number)]['title_localized']['en'])
local result="[[file:Songs_"..id..".jpg|100px|link="..title.."]]"
return result
end
return p