Custom (image) Content Provider - image doesn't render in edit mode

Bob Maes
Member since: 2017
 

Hello,

I'm in the middle of implementing a custom content provider to server images from an external dam system.

I've got almost everything running, except, I have no images in on page edit mode.

My content provider returns a custom IContent type that inhertits from ImageData, this to blend in as best as possible in epi.
Behind it I have a custom blobprovider to stream images from the dam.

Thumbnails in the shell works, as well as the rendering on the public site. But I don't see any images in edit mode.
And I think the problems lies how epi generates it url's.

If I use an image from de default media library, the url to an image in edit mode is the following:
http://localhost:1812/EPiServer/CMS/Content/globalassets/en/demo/cotton/farm2.jpg,,14?epieditmode=False

But when I use an image from my provider, it's like this:
http://localhost:1812/EPiServer/CMS/Content/en/dam/9FCBB804-89E5-4443-8D969A9265D74B3B-home-banner.jpg,,1__bynder?epieditmode=True

If I open this url, it triggers 2 requests:

  1. http://localhost:1812/EPiServer/CMS/Content/en/dam/9FCBB804-89E5-4443-8D969A9265D74B3B-home-banner.jpg,,1__bynder?epieditmode=True
    Content-Type:text/html; charset=utf-8
  2. http://localhost:1812/EPiServer/CMS/Content/en/dam/9FCBB804-89E5-4443-8D969A9265D74B3B-home-banner.jpg,,1__bynder?epieditmode=False
    Content-Type:image/jpeg

When I use the edit action menu in the assets pane, it immediately renders the following (correct?) url:
http://localhost:1812/EPiServer/CMS/Content/en/dam/9FCBB804-89E5-4443-8D969A9265D74B3B-home-banner.jpg,,1__bynder?epieditmode=False
Content-Type:image/jpeg

Does anybody already encountered this? Any idea how to resolve this?

Many thanks,

bob

#186153 Dec 13, 2017 7:29
  • Drew Null
    Member since: 2013
     

    Bob did you ever get this figured out? 

    #196980 Sep 19, 2018 5:03
  •  

    I'm experiencing the same problem. Did you ever find a solution?

    #197301 Sep 28, 2018 14:55
  • Bob Maes
    Member since: 2017
     

    Hello,

    it's been awhile but I think the following code fixed the issue:

    I registered a route in the initialization module of my provider (IInitializableModule.Initialize)

            public void Initialize(InitializationEngine context)
            {
                var settings = context.Locate.Advanced.GetInstance<IBynderSettings>();
                var bynderRoot = EnsureCreateProviderRoot(context, settings);
    
                EnsureProvider(context, bynderRoot);
    
                EnsureRoutes(bynderRoot);
            }
    
            private void EnsureRoutes(IContent bynderRoot)
            {
                // Since we have our structure outside asset root we registera custom route for it
                // and remove the language segment
                // -> disabled for the moment, we want content to be localizable
                //RouteTable.Routes.MapContentRoute(
                //name: "BynderMedia",
                //    url: "bynder/{node}/{partial}/{action}",
                //    defaults: new { action = "index" },
                //    contentRootResolver: (s) => bynderRoot.ContentLink);
    
                // EPiServer UI needs the language segment
                RouteTable.Routes.MapContentRoute(
                    name: "BynderMediaEdit",
                    url: CmsHomePath + "bynder/{language}/{medianodeedit}/{partial}/{action}",
                    defaults: new { action = "index" },
                    contentRootResolver: (s) => bynderRoot.ContentLink);
            }
    
            private static string CmsHomePath
            {
                get
                {
                    var cmsContentPath = VirtualPathUtility.AppendTrailingSlash(EPiServer.Shell.Paths.ToResource("CMS", "Content"));
                    return VirtualPathUtilityEx.ToAppRelative(cmsContentPath).Substring(1);
                }
            }

    Sorry for the slow response, and not updating my post in the first place...

    bob

    #197306 Sep 28, 2018 17:10
  •  

    Thanks for the response Bob!
    I tried your solution but didn't get it to work (even though it seems like it should). My solution instead were to change the content provider root from the root folder and instead use the global asset root. The content provider root folder were then visible in the media asset folder structure as well, but that wasn't a big problem for me.

    #197725 Oct 11, 2018 13:58