New API Players:GetUserThumbnailAsync()

This API allows you to get the Content URL for a user thumbnail and check if it is generated (i.e not N/A). If the requested image is N/A then it will be added to the thumbnail queue to be generated. The API can be called multiple times until the image is ready to be displayed.

The full method signature is as follows:

-- The first return value is the image URL
-- The second is a bool indicating whether the image is generated or not,
-- if this is false then the image will be N/A when displayed.
Content, bool GetUserThumbnailAsync (
    int userId,
    ThumbnailType thumbnailType,
    ThumbnailSize thumbnailSize
)

Here is the Roblox wiki page with more information:

For an example of how this can be used to avoid showing N/A thumbnails or regenerate N/A thumbnails see this upcoming CoreScripts change which uses the API to avoid showing N/A user thumbnails in the Core UI where possible.

51 Likes

Is thumbnail size still limited to 420p or can we edit it now?

1 Like

It’s still limited to 420x420 right now, I think we can look into increasing the size or adding more size options in the future though.

@Iron_Legion or @Brouhahaha might know why the thumbnail size limits are what they are.

7 Likes

Can this be called from a local script?

Yes, it is intended to be used with LocalScripts. Test before you ask :wink:!

2 Likes

Thanks. And I assume that no thumbnail gets returned for guests. My tests on a local server returns an image for negative user ids, but it is a generic “broken” image, and not the real thumbnail of the player.

1 Like

It’s new? I thought I saw these functions before.

Either way, thank you for this. Now I don’t have to do intense digging or write out odd lines of code. Pump this function out, get beautiful code organization and what I need without complications.

No, these aren’t brand new – they’ve been out since May. This thread was recently bumped which is why you’re seeing it now.

my face when

So I did see them before. I didn’t check the post date.

Lacks support for 250x250 thumbnail size.

1 Like

why so specific?

Just putting random resolutions in the thumbnail url doesn’t generate any picture, but the resolution 250x250 does, so it should be a ThumbnailSize enum aswell.

1 Like

So the useage for this is… when a player joins, loop through all players in the game and call this function on their userid to ensure the avatars get generated.
Then set up a player added event locally and call this function on each new player that joins?

1 Like

You don’t need to pre-generate all the user thumbnails necessarily, you can use this function to spend a few seconds retrying to get the thumbnail while the N/A image is displayed.

A good example of this is the following function used by the CoreScripts which will try to get the valid thumbnail image for a few seconds before falling back to the possibly N/A thumbnail link:

3 Likes