Module:LPDB/teamcardimage

local p = {}

local getArgs = require('Module:Arguments').getArgs local args

function p.get(frame) args = getArgs(frame) local lpdbResult = mw.ext.LiquipediaDB.lpdb('datapoint', {		conditions = 'type::teamcardimage AND name::' .. mw.ext.TeamLiquidIntegration.resolve_redirect(args[1]) ..' AND extradata_startdate::<=' .. args['date'] ..' AND extradata_enddate::>' .. args['date'] ..'',		query = 'image',		limit = 1	})[1] or {} if not lpdbResult.image then lpdbResult = mw.ext.LiquipediaDB.lpdb('team', {			conditions = 'pagename::' .. string.gsub(mw.ext.TeamLiquidIntegration.resolve_redirect(args[1]), ' ', '_') .. '',			query = 'logo',			limit = 1		})[1] or {} end if not (lpdbResult.image or lpdbResult.logo) or lpdbResult.logo == '' then return args['default'] or '' end return lpdbResult.image or lpdbResult.logo end

return p