2

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?

1 Answer 1

2

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?

2
  • This is really some heavy lifting to tokenize the datasource for an image. But it looks right.
    – Chris Auer
    Feb 25, 2019 at 5:08
  • It's definitely non-trivial, but it's also fairly boilerplate and doesn't require much customization between implementations, so you can basically re-use it directly. Feb 25, 2019 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.