How do I grab the thumbnail of a bundle?

So in my game, I use an API to get the thumbnail of items based on their asset id. However, with bundles, since they aren’t a real asset id or what not it won’t allow this. Do I use GetBundleDetailsAsync()? The only thing is I don’t know exactly what to grab from that because it has the asset ids of the limbs, and hats, but also hat a UserOutfit asset id and when I try to use that it doesn’t work either.
API I use:
https://www.roblox.com/Thumbs/Asset.ashx?width=420&height=420&assetId=ID

Return from GetBundleDetailsAsync();

 {"BundleType":"BodyParts","Name":"Halloween Witch","Id":203,"Description":"\"In Witchcraft, each of us must reveal our own truth.\"","Items":[{"Name":"Halloween Witch Left Arm","Type":"Asset","Id":132896993},{"Name":"Halloween Witch Right Arm","Type":"Asset","Id":132897065},{"Name":"Halloween Witch Left Leg","Type":"Asset","Id":132897097},{"Name":"Halloween Witch Right Leg","Type":"Asset","Id":132897160},{"Name":"Halloween Witch Torso","Type":"Asset","Id":132897194},{"Name":"Halloween Witch Hat","Type":"Asset","Id":132897230},{"Name":"Halloween Witch","Type":"UserOutfit","Id":131929451}]}
  Witch

Please make a reply containing your solution and mark that reply as the solution. That will make it easier to weed out who still has problems, and more importantly help anyone who still has this problem in the future.

4 Likes

What I ended up doing was this

local bundleAssetId
local itemAsync = Services:GetService("AssetService"):GetBundleDetailsAsync(Index.Bundles[name].ID)
	for i,v in pairs(itemAsync.Items) do
		if itemAsync.Items[i].Type == "UserOutfit" then
			bundleAssetId = itemAsync.Items[i].Id
		end
	end
return string.format("http://roblox.com/outfit-thumbnail/image?userOutfitId=%d&width=150&height=150&format=Png", bundleAssetId)
2 Likes

Note that I have a module that grabs roblox services and my module scripts so the Services:GetService() is the exact same as game:GetService()

You should break your for loop once you’ve gotten the information you require.

local bundleAssetId do
    local itemAsync = Services:GetService("AssetService"):GetBundleDetailsAsync(Index.Bundles[name].ID)
	for i,v in pairs(itemAsync.Items) do
		if itemAsync.Items[i].Type == "UserOutfit" then
			bundleAssetId = itemAsync.Items[i].Id
			break
		end
	end
end

return string.format("http://roblox.com/outfit-thumbnail/image?userOutfitId=%d&width=150&height=150&format=Png", bundleAssetId)

Figure you should stop checking through something when you don’t need to anymore.

5 Likes

Thanks I had that in my code already :wink: this was just a quick copy

1 Like