Add new default placeholder avatars

This commit is contained in:
Jesse Wierzbinski 2024-04-07 17:55:12 -10:00
parent 6917def011
commit e4f82e2fa9
No known key found for this signature in database
3 changed files with 12 additions and 2 deletions

View file

@ -246,10 +246,12 @@ allowed_mime_types = [
visibility = "public" visibility = "public"
# Default language for new notes (ISO code) # Default language for new notes (ISO code)
language = "en" language = "en"
# Default avatar, must be a valid URL or "" for none # Default avatar, must be a valid URL or "" for a placeholder avatar
avatar = "" avatar = ""
# Default header, must be a valid URL or "" for none # Default header, must be a valid URL or "" for none
header = "" header = ""
# A style name from https://www.dicebear.com/styles
placeholder_style = "thumbs"
[federation] [federation]
# This is a list of domain names, such as "mastodon.social" or "pleroma.site" # This is a list of domain names, such as "mastodon.social" or "pleroma.site"

View file

@ -34,7 +34,11 @@ export type UserWithRelations = Prisma.UserGetPayload<typeof userRelations2>;
* @returns The raw URL for the user's avatar * @returns The raw URL for the user's avatar
*/ */
export const getAvatarUrl = (user: User, config: Config) => { export const getAvatarUrl = (user: User, config: Config) => {
if (!user.avatar) return config.defaults.avatar; if (!user.avatar)
return (
config.defaults.avatar ||
`https://api.dicebear.com/8.x/${config.defaults.placeholder_style}/svg?seed=${user.username}`
);
return getUrl(user.avatar, config); return getUrl(user.avatar, config);
}; };

View file

@ -260,6 +260,9 @@ export interface Config {
/** @default "" */ /** @default "" */
header: string; header: string;
/** @default "thumbs" */
placeholder_style: string;
}; };
federation: { federation: {
@ -540,6 +543,7 @@ export const defaultConfig: Config = {
language: "en", language: "en",
avatar: "", avatar: "",
header: "", header: "",
placeholder_style: "thumbs",
}, },
federation: { federation: {
blocked: [], blocked: [],