Documentation for this module may be created at ሞድዩል:Wikidata/Image format/doc

local p = {}

function p.imageFormat( value, options, frame, qualifyings )
	local Format, alignment, size, description, alternative, link
	
	if options then
		Format      = options['image format']
		alignment   = options['image alignment']
		size        = options['image size']
		description = options['image description']
		alternative = options['alternative text image']
		link        = options['image link']
	end
	
    if qualifyings and not description then
    	local imageFooters = qualifyings.P2096
    	local k,imageFooter
    		
    	-- Find the Tigrinya footer (the one with datavalue.value.language = "ti")
    	if imageFooters then
    		for k,imageFooter in pairs(imageFooters) do
    			if imageFooter.datavalue.value.language=='ti' then
					description = imageFooter.datavalue.value.text
				end
			end
		end
	end

	local result = '[[File:' .. value
	
	if Format and Format ~='' then
		result = result .. '|' .. Format
	end
	
	if alignment and alignment ~='' then
		result = result .. '|' .. alignment
	end	
	
	if size and size ~='' then
		result = result .. '|' .. size
	end
	
	if alternative and alternative ~='' then
		result = result .. '|alt=' .. alternative
	end

	if link and link ~='' then
		result = result .. '|link=' .. link
	end
	
	if not description or description =='' then
		return result .. ']]'
	elseif Format == 'thumb' then
		return result .. '|' .. description .. ']]'
	else
		return result .. ']]' .. '<br /><span>' .. description .. '</span>'
	end			
end

--*****************************************************************************
-- Format aliases to use in the property template
--*****************************************************************************
p['image']      = p['imageFormat']
	
return p