How to get the name of an asset by assettypeId?

I’m looping through a players favorites and I’m creating an image label for each favorite. I’m then setting the image of the image to the favorited item that’s currently being looped. I already have a list of their favorites the problem is just setting the image to be that favorited item’s image


It still resulted in this. Maybe rbxthumb://type= doesnt work with assettypeid or something?

could you try printing this?

function getAssetType(assettype)
	for i, v in ipairs(Enum.AssetType:GetEnumItems()) do
		if assettype == v.Value then
			return v.Name
		end
	end
end

---later again

print(getAssetType(v.Item.AssetType))

Oh hold on, hold on, I see the problem. AssetType also contains other things other than just what we wanted.

What other information does it give? I printed it and it gave me a valid name

https://developer.roblox.com/en-us/api-reference/enum/AssetType

Alright, just to make sure, you have tried this right?

clone.Image = v.Thumbnail.Url

Actually, I realize your problem now that I looked at the item closer. The problem is that you are trying to get the thumbnail to an AUDIO, which doesn’t have a thumbnail. So, what I provided earlier

should actually work fine. The only problem is that you would need to check whether or not you need a thumbnail for the item to be shown.

I don’t get their favorite audios. None of the images worked however the clone pops up

Are there any errors in the console?

there are none. I believe the issue is that (I THINK) assettype’s and rbxthumb://type= dont work the same way. I might have to make a dictionary if so

Well, you could also just use this I believe:

clone.Image = "rbxassetid://"..v.Item.AssetId

Now, I’m not sure if this works with games, so you will have to test that

It does the same thing as rbxthumb://type= which is REALLY weird… I don’t know whats going on

No errors just this:
image

How about

clone.Image = "asset-thumbnail/imageassetId="..v.Item.AssetId.."&width=420&height=420"

This is a REALLY old way, so I wouldn’t be surprised if it didn’t work tbh

It has the same results as the other ones. Something I want to note is that the image was stuff like: rbxasset://textures/ui/GuiImagePlaceholder.png

You need to map the ‘AssetType’ field of each asset to a corresponding ‘rbxthumb’ type.

2 Likes

Firstly you would get the ID of the asset and Second you would use Roblox’s Market Asset API to get the name of the asset. https://api.roblox.com/Marketplace/ProductInfo?assetId=000000. You would also use the GetProductInfo Function for this. This is just a short summary on how to do it.