<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MediaProvider &#8211; blog.boro2g .co.uk</title>
	<atom:link href="https://blog.boro2g.co.uk/tag/mediaprovider/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.boro2g.co.uk</link>
	<description>Some ideas about coding, dev and all things online.</description>
	<lastBuildDate>Thu, 16 Jun 2011 12:48:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.8</generator>
	<item>
		<title>Setup custom Sitecore MediaProvider</title>
		<link>https://blog.boro2g.co.uk/setup-custom-sitecore-mediaprovider/</link>
					<comments>https://blog.boro2g.co.uk/setup-custom-sitecore-mediaprovider/#comments</comments>
		
		<dc:creator><![CDATA[boro]]></dc:creator>
		<pubDate>Thu, 16 Jun 2011 12:48:06 +0000</pubDate>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[MediaProvider]]></category>
		<category><![CDATA[sitecore]]></category>
		<guid isPermaLink="false">http://blog.boro2g.co.uk/?p=73</guid>

					<description><![CDATA[<p>One of Sitecore&#8217;s most useful features is the plug-ability of functionality via the configuration factory. Its very easy to add or update custom implementations where necessary. A typical programming model used throughout this is the Provider model &#8211; Membership, Roles, Item, Proxy&#8230; the list is endless. Unfortunately one provider thats not exposed in the config [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.boro2g.co.uk/setup-custom-sitecore-mediaprovider/">Setup custom Sitecore MediaProvider</a> appeared first on <a rel="nofollow" href="https://blog.boro2g.co.uk">blog.boro2g .co.uk</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>One of Sitecore&#8217;s most useful features is the plug-ability of functionality via the configuration factory. Its very easy to add or update custom implementations where necessary.</p>
<p>A typical programming model used throughout this is the Provider model &#8211; Membership, Roles, Item, Proxy&#8230; the list is endless. Unfortunately one provider thats not exposed in the config factory is the MediaProvider.</p>
<p>No problem, thanks to some help from support they suggested a way to get around this, you can tap into the initialise pipeline. Here is the patch file to enable this:</p><pre class="crayon-plain-tag">&amp;lt;configuration xmlns:patch=&amp;quot;http://www.sitecore.net/xmlconfig/&amp;quot;&amp;gt;
  &amp;lt;sitecore&amp;gt;
    &amp;lt;pipelines&amp;gt;
      &amp;lt;initialize&amp;gt;
        &amp;lt;processor patch:after=&amp;quot;processor[@type='Sitecore.Pipelines.Loader.EnsureAnonymousUsers, Sitecore.Kernel']&amp;quot; type=&amp;quot;###.Domain.Cms.Specialization.Pipelines.Loader.InitializeMediaProvider, ###.Domain.Cms&amp;quot; /&amp;gt;
      &amp;lt;/initialize&amp;gt;
    &amp;lt;/pipelines&amp;gt;   
  &amp;lt;/sitecore&amp;gt;
&amp;lt;/configuration&amp;gt;</pre><p>This pipeline runs as the application intializes. Next you need the implementation of the pipeline processor:</p><pre class="crayon-plain-tag">using Sitecore.Diagnostics;
using Sitecore.Pipelines;
using Sitecore.Resources.Media;

namespace ###.Domain.Cms.Specialization.Pipelines.Loader
{
    /// &amp;lt;summary&amp;gt;
    /// Sets the Provider for Sitecore's MediaManager to a custom version.
    /// &amp;lt;/summary&amp;gt;
    public class InitializeMediaProvider
    {
        public void Process(PipelineArgs args)
        {
            Assert.IsNotNull(args, &amp;quot;args&amp;quot;);

            MediaManager.Provider = new ###.Domain.Cms.Specialization.Resources.Media.MediaProvider();
        }
    }
}</pre><p>And finally the custom implementation:</p><pre class="crayon-plain-tag">namespace ###.Domain.Cms.Specialization.Resources.Media
{
    public class MediaProvider : Sitecore.Resources.Media.MediaProvider
    {
        public override string GetMediaUrl(MediaItem item, MediaUrlOptions options)
        {
            ...
        }
    }
}</pre><p>Our customization allowed us to push certain media extensions to known file types.</p>
<p>The post <a rel="nofollow" href="https://blog.boro2g.co.uk/setup-custom-sitecore-mediaprovider/">Setup custom Sitecore MediaProvider</a> appeared first on <a rel="nofollow" href="https://blog.boro2g.co.uk">blog.boro2g .co.uk</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.boro2g.co.uk/setup-custom-sitecore-mediaprovider/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
