Module:Link

local Link = {} local HF = require('Module:HF') local getArgs = require('Dev:Arguments').getArgs

local function FileLink( page, ... ) -- get the extra arguments as a table local args = { ... }   -- get the count of extra arguments, correctly local n = select( '#', ... ) local placeholder = table.concat( args, '|', 1, n ) return HF.Link( 'File:' .. page .. (n > 0 and '|' .. placeholder or '')) end function Link.main(frame) local args = getArgs(frame) return Link._main(args) end

function Link._main(args) local img = args['img'] and FileLink( args['img'], 'x30px' ) or nil local _type = args['type'] and (type_values[args['type']] or nil) or nil local primary = args[1] local secondary = args[2] if not primary then return nil end local type_values = { item = FileLink(           primary .. '.png',            ('alt=Item image of %s, %s'):format( mw.uri.encode( '') -- This doesn't seem right 'File:' .. primary .. '.png' )       ),        npc = FileLink(            primary .. '.png',            'x30px',            ('alt=NPC image of %s, %s'):format( primary, 'File:' .. primary .. '.png' )       ),        chat = FileLink(            primary .. ' chathead.png',            'x30px',            ('alt=Chat head image of %s, %s'):format( primary, 'File:' .. primary .. ' chathead.png' )       ),        music = FileLink('Music.png'), skill = FileLink(           primary .. ' icon.png',            ('alt=Skill icon of %s, %s'):format( primary, 'File:' .. primary .. ' icon.png' )       )    }    local image = img or _type or FileLink('Placeholder.png',('alt=Link to %s'):format(primary)) local link = HF.Link(primary, secondary or nil) return image .. link end return Link