public static function getExtFromType($type, $primary = false) {
        $exts = array();

        foreach (self::$_types as $ext => $mimeType) {
            $isPrimary = false;

            if (is_array($mimeType)) {
                $mimeType = $mimeType[0];
                $isPrimary = $mimeType[1];
            }

            if ($mimeType == $type) {
                if ($primary && $isPrimary) {
                    return $ext;
                }

                $exts[] = $ext;
            }
        }

        if ($primary && isset($exts[0])) {
            return $exts[0];
        }

        return $exts;
    }