Мазмунга өтүү

Модуль:Wikidata/media

Википедия дан

Documentation for this module may be created at Модуль:Wikidata/media/doc

local p = {}

function p.formatCommonsCategory( context, options, value )
    local link = 'commons:Category:' .. value
    local title = value
    if ( options['text'] and options['text'] ~= '' ) then
    	title = options['text']
    end

	commons = '[[' .. link .. '|' .. title .. ']]'

	--Commons icon
    if ( options['icon'] and options['icon'] ~= '' ) then
    	local icon_size = '15px'
    	if ( options['icon_size'] and options['icon_size'] ~= '' ) then
    		icon_size = options['icon_size']
    	end
    	commons = '[[File:Commons-logo.svg|' .. icon_size .. '|link=' .. link .. ']] ' .. commons
    end

	--Text before and after link
    if ( options['text_before'] and options['text_before'] ~= '' ) then
    	commons = options['text_before'] .. ' ' .. commons
    end
    if ( options['text_after'] and options['text_after'] ~= '' ) then
    	commons =  commons .. ' ' .. options['text_after']
    end
	
    return commons
end

function p.formatImage( context, options, value )
	local image = '[[File:' .. value
    if options['size'] and options['size'] ~= '' then
    	image = image .. '|' .. options['size']
    end
    if options['alt'] and options['alt'] ~= '' then
    	image = image .. '|' .. options['alt']
    end
	image = image .. ']]'
	
    return image
end

return p