If you have spaces in your Media Library item names, this will be important to you.
While upgrading a client to Sitecore 7.2 this section of the release notes gave us pause:
When rendering media URLs, the system did not use the configuration in the encodeNameReplacements section to replace special characters in the URLs. This has been fixed so that media URLs also use the encodeNameReplacements configuration. (323105, 314977)
Summary: media library URLs now use the encodeNameReplacements configuration.
This will affect your Sitecore install if:
This definitely applies to a few our instances. Mostly because the Media Library takes the original assets filename as the items name. Filenames are often formatted with hyphens.
Use Sitecore Powershell or something similar to execute code, removing all hyphens from Media Library names. For us this approach had the following drawbacks:
Replace Sitecore's MediaProvider with our own, removing the newly added encodeNamesReplacement functionality for Media Library items.
We're going with Option 2. It's the best option for us when accounting for timelines, stability and the drawbacks of our specific situation outlined in Option 1 listed above.
We're doing Option 2 which means we're using our own MediaProvider and removing the encodeNamesReplacement functionality.
All code for this patch is on GitHub under the Fishtank.MediaResolverPatch.
We have 3 files that we'll compile into one assembly:
To use this, we'll find the mediaProvider section in the web.config and swap out the class and assembly. It's located at configuration > sitecore > mediaLibrary > mediaProvider.
<!-- MEDIA PROVIDER
The media provider used to generate URLs, create media items, control media caching, parse media requests, and other
media related functionality.
<!-- <mediaProvider type="Sitecore.Resources.Media.MediaProvider, Sitecore.Kernel"/>-- >
<mediaProvider type="Fishtank.MediaResolverPatch.FishtankMediaProvider, Fishtank.MediaResolverPatch" />
Now we've successfully reverted Sitecore 7.2 to resolve and render Media Library URLs as it did pre-upgrade. Again, all code is on GitHub.
We will keep Option 1 in our pocket as part of our next major-version Sitecore upgrade.
Thanks for reading. This article was authored using Markdown for Sitecore.