Field source tokens for media items like image field

Kayden: 5 days ago

I have been using tokens for a while, patching in a processor to the getLookupSourceItems pipelines and transforming a token like $siteName$ into the site name. Or $site$ into the the current sites root path.

But in field sources for media items like an image field, this pipeline is never hit. I would like to replace the $siteName with the current site's name. This isn't rendering datasources. This is a template's field source.

I get the following error since my field source is not transformed.

The source of this Image field points to an item that does not exist.

/sitecore/media library/Images/$siteName would become /sitecore/media library/Images/SiteA

Any thoughts on what pipeline is controlling media field sources?

Emma: 5 days ago

This doesn't directly answer your question, but a common way of doing what you are asking is to implement your own image field control. You basically override Sitecore.Shell.Applications.ContentEditor.Image and override the Source property and replace the token at that point.

There is an example of this found at How to change the source from an image field programmatically? (