function addPlayerPicFromFileName($playerId, $filename, $name) { if (!$name) { $name = $playerId . "_player_pic"; } $newMediaResultData = Media::createMedia("player", $name, $filename, 0); $newMediaId = $newMediaResultData->data->media_id; Players::addPlayerPic($playerId, $newMediaId); $returnObj->media_id = $newMediaId; return new returnData(0, $returnObj); }