Create an image of the outfitString

I am currently on a dashboard which is open as an external window. I got the avatar name and can display this on the external site. Now I would like to show an image of the avatar.

Is there an easy way to get a single “image” of the avatar from the outfitString. Or a function that “compiles” the outfitString to HTML or whatever?

Thanks 4 Infos or ideas

1 Like

Hi @informatics, have you find a way to do this? May you share your approach? Thanks.

Hey @bentinata,

this was the code used, to create from a user object an avatar Url.

I basically reversenginieerg, what I found in the web version … but the commit is 2 years old

Cheers Info

2 Likes

@bentinata This typescript function will give you a gather.town URL with the avatar image.
I’ve been using it without any issues so far.

export const getPlayerAvatar = (player: Partial<Player>) => {
  if (!player) return "";

  const outfit: DBOutfit = player.currentlyEquippedWearables!;
  const profileImageParts = Object.values(outfit)
    .filter((outfitLayer) => outfitLayer)
    .join(".");

  return `https://dynamic-assets.gather.town/v2/sprite-profile/avatar-${profileImageParts}.png?d=.`;
};
3 Likes