User Data & Bazaar causing weird behavior when changing creature/token image

In typical Foundry behavior, if you drag a creature from a compendium, and change the art for the creature, it will automatically update the token art as well to have the same art.

The only time it will not do this is if the token already has a non-default art set.

However, in Forge, there is an issue with this behavior. When you drag a creature from the compendium, the default Foundry Guy art will be linked to the compendium instead of the default path Foundry expects. If you change the art for that creature, it will update fine, but the token’s art will not be updated automatically - it will remain default Foundry Guy.

I suspect this is because the token’s art is not the “default path”, it’s the Bazaar path.

It’s not a huge deal, but it is fairly annoying to have to update the art in two places as opposed to the correct Foundry behavior which should update both at once.

FYI, this behavior actually works fine if you create a new creature manually (instead of dragging one from the compendium). In this case, the default art points to the User Data directory path instead of the Bazaar path, and when you update the creature art, it also updates the token art as expected.

1 Like

I believe the “update both Character + Token” is actually a Module performing that, unless I missed a feature change in core FoundryVTT.

Nope. This is a default Foundry behavior. I can repeat this with no modules, and I definitely don’t have that module installed.

If I had to guess what is happening is the image paths in the Compendiums have been replaced via some script, which lets Forge save money on storage costs by hosting a single copy of all the module/system artwork, instead of duplicating those things in each user’s User Data directory. Deduping that data makes sense.

However, since the Foundry Guy (“mystery-man.svg” in 5E) is already in the User Data path anyway, since presumably Foundry expects it there for other features, I think what needs to happen is the string replace code that changes the file paths in compendiums needs to ignore any strings with the “mystery-man.svg” art and let it naturally point to the User Data path.

Very nice catch!
You’re right, if the prototype token is exactly set to “icons/svg/mystery-man.svg”, then Foundry will update the prototype token when an actor image is updated, but since the Forge optimizes the URL to use the assets library/CDN, it doesn’t match anymore since it becomes https://assets.forge-vtt.com/bazaar/core/icons/svg/mystery-man.svg
I’ve fixed it now so it won’t do that for future updates to compendium modules and systems. I’ll push the update later today!
Thanks for reporting your issue!

EDIT: Just saw your latest comment, note that it’s not about deduping the data, it’s more about having it all go through the same URL so it goes through the CDN and it’s more optimal for caching (since the same URL will be accessed by many players and it will likely be cached by your closest CDN location, rather than being a unique url in your game’s subdomain, so it gets re-fetched every time). Your suggested fix is exactly what I ended up doing.

1 Like

I was today years old when I learned.

Very well well diagnosed and written up. Very much appreciate people who take the time to look into things thoroughly.

Thanks for the quick reply & fix!

You probably thought of this, but just in case… annoyingly, it looks like other systems use a different name/path for the same type of file. In Pathfinder 2E the default creature token is “systems/pf2e/icons/default-icons/npc.svg” which is getting replaced with “https://assets.forge-vtt.com/bazaar/systems/pf2e/assets/icons/default-icons/npc.svg”.

And yeah that makes sense with the CDN. Thank you for the explanation. :slight_smile:

1 Like

Yeah… that’s fun…
This is the portion of the Foundry code that does it, so it checks for CONST.DEFAULT_TOKEN


But that’s a CONST so it can’t be changed, and in a pf2e game, it is indeed still the same value… and yet, the default token is systems/pf2e/icons/default-icons/mystery-man.svg and it does change when I create a new actor then change its avatar… so… I don’t know, it might be that the system does the same kind of logic in its own code but checking for a different variable, that sounds quite hard to predict.
I’ll have a look and see if there’s a specific list of paths we’d need to handle differently.
Thanks again!

It sounds like instead of not optimizing the path on the server side during package updates, it would be better to have a Hooks.on("preActorUpdate") and just do the same logic as screenshotted above, from the foundry client side via the Forge module instead, and check for the bazaar link. That way it would work seamlessly regardless of the game system.
Just need to find where the system stores its DEFAULT_TOKEN variable :slight_smile:

Yeah, I think you are exactly right. Looks like PF2E system devs are overriding the replace logic from Foundry default in PF2E system here. And generating the path based on the type of object it is I guess, so they don’t have one specific default token - it would depend if it’s a PC, NPC, vehicle, etc. Good news is I doubt many other systems do this.

e: here’s the constant for most of the types: pf2e/values.ts at master · foundryvtt/pf2e · GitHub. Didn’t see the other types like vehicle etc.

e2: Maybe you could submit a system PR to add in a Forge reference there… adding https://assets.forge-vtt.com/bazaar/systems/pf2e/assets/icons/default-icons/${this.type}.svg as a default image would fix it I think? They already included a Forge reference elsewhere.

1 Like