Module:Wikidata/media

Уикипедия — ашық энциклопедиясынан алынған мәлімет
Навигацияға өту Іздеуге өту

Бұл модульдің құжаттамасын Module: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 ( not options['icon'] or 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
    	if ( options['text_before'] ~= '-' ) then
	    	commons = options['text_before'] .. ' ' .. commons
	    end
	else
    	commons = '\'\'\' ' .. commons
    end

    if ( options['text_after'] and options['text_after'] ~= '' ) then
    	if ( options['text_after'] ~= '-' ) then
	    	commons =  commons .. ' ' .. options['text_after']
	    end
	else
		commons =  commons .. ' \'\'\' [[Ортаққор]]да'
    end
	
    return commons
end

function p.formatCommonsMedia( value, options, context )
	local image = '[[File:' .. value
	if options['border'] and options['border'] ~= '' then
    	image = image .. '|border'
    end

   	local size = options['size']
    if size and size ~= '' then
    	if not string.match( size, 'px$' )
			and not string.match( size, 'пкс$' )
		then
    		size = size .. 'px'
    	end
	else
		size = '250x350px'
    end
	image = image .. '|' .. size

    if options['alt'] and options['alt'] ~= '' then
    	image = image .. '|' .. options['alt']
    end
	image = image .. ']]'
	
    return image
end

return p