Module:SpriteFile: Difference between revisions

Replace Module:Sprite
 
No edit summary
Line 24: Line 24:
if mw.ustring.lower( link ) == 'none' then
if mw.ustring.lower( link ) == 'none' then
link = ''
link = ''
else
local linkPrefix = ( not link:find( '//' ) and args.linkprefix ) or ''
link = linkPrefix .. link
end
end
local scale = args.scale or default.scale
local scale = args.scale or default.scale
local height = ( args.height or args.size or default.size ) * scale
local width = ( args.width or args.size or default.size ) * scale
local width = ( args.width or args.size or default.size ) * scale
local height = ( args.height or args.size or default.size ) * scale
local size = width .. 'x' .. height .. 'px'
local size = width .. 'x' .. height .. 'px'
local styles = {}
if height ~= default.size then
styles[#styles + 1] = 'height:' .. height .. 'px'
end
if width ~= default.size then
styles[#styles + 1] = 'width:' .. width .. 'px'
end
local file = args.name .. ' ' .. id .. '.png'
local file = args.name .. ' ' .. id .. '.png'
local sprite = mw.html.create( 'span' ):addClass( 'sprite-file' )
local sprite = mw.html.create( 'span' ):addClass( 'sprite-file' )
sprite:node( '[[File:' .. file .. '|' .. size .. '|link=' .. link .. '|' .. ( args.title or '' ) .. '|class=pixel-image]]' )
local img = '[[File:' .. file .. '|' .. size .. '|link=' .. link .. '|class=pixel-image|' .. ( args.title or '' ) .. ']]'
sprite:node( img )
local styles = {}
local align = args.align or default.align
local align = args.align or default.align
Line 59: Line 69:
if link:find( '//' ) then
if link:find( '//' ) then
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
else
spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
end
end
-- Internal link
local linkPrefix = args.linkprefix or ''
spriteText = '[[' .. linkPrefix .. link .. '|' .. tostring( spriteText ) .. ']]'
end
end
end
end