We recently had a requirement when one of our external vendors required that our media URLs should not include the "~" in the link as their system could not process those correctly.
I found a few articles in the web, but most of them would suggest changing the default behavior, i.e. any "new" media item would have the 'new' replacement character though still supporting the tilde "~".
Based on the web articles, I started with the following config keys and section:
I found a few articles in the web, but most of them would suggest changing the default behavior, i.e. any "new" media item would have the 'new' replacement character though still supporting the tilde "~".
Based on the web articles, I started with the following config keys and section:
- Media.RequestExtension
- Media.MediaLinkPrefix
- customHandlers
We did not want to change any of the default behaviors, we just needed a way to make Sitecore support the additional URL media prefix.
While sifting through the configuration, I chanced upon the following section:
- <mediaPrefixes>
According to the comment above it:
Allows you to configure additional media prefixes (in addition to the prefix defined by the Media.MediaLinkPrefix setting)
The prefixes are used by Sitecore to recognize media URLs.
Notice: For each custom media prefix, you must also add a corresponding entry to the <customHandlers> section
With that we now have our solution:
Using the Include config file contents below, we have now basically added additional media prefix support without changing the default behavior:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<mediaLibrary>
<mediaPrefixes>
<prefix value="-/media"/>
</mediaPrefixes>
</mediaLibrary>
<customHandlers>
<handler trigger="-/media/" handler="sitecore_media.ashx"/>
</customHandlers>
</sitecore>
</configuration>
Comments
Post a Comment