You need register the new Media Manager using Sitecore Dependency Injection (see 'Registration in code' chapter). It can be done via Service Configurator as described in the article.
Creating Service Configurator
Implement Sitecore.DependencyInjection.IServicesConfigurator
interface from Kernel assembly. Please note that you need to reference Microsoft
Dependency Injection 1.0.0 NuGet package:
public class ServiceConfigurator : IServicesConfigurator
{
public void Configure(IServiceCollection serviceCollection)
{
serviceCollection.AddSingleton<BaseMediaManager>(s =>
new MyMediaManager(
new DefaultMediaManager(
s.GetService<BaseFactory>(),
s.GetService<MediaProvider>()
)));
}
}
Implementing Media Manager
You may inherit the DefaultMediaManager
class as you mentioned but in case of numerous changes required (probably by different teams) composition might be a better choise):
public class MyMediaManager : BaseMediaManager
{
private readonly BaseMediaManager _mediaManager;
public MyMediaManager(BaseMediaManager mediaManager)
{
_mediaManager = mediaManager;
}
public override Media GetMedia(MediaItem item)
{
// add you custom logic here
return _mediaManager.GetMedia(item);
}
...
}
Registering Service Configurator
Last step, add the following registration to your configuration files:
<configuration>
<sitecore>
<services>
<configurator type="<younamespace>.DependencyInjection.ServiceConfigurator, <yourassembly>"/>
</services>
</sitecore>
</configuration>
mediaProvider
is not a pipeline, it is a single type setting.MediaProvider
has also (incorrectly?) been marked as[Obsolete]
but no alternative has been provided to use, and Sitecore itself is using it as the default provider, so you'll have to ignore the warning, maybe disable it...