How to use UmbracoEntity & ThumbnailProvidersResolver?
Hi,
I'm trying to customize some things in the media Folder Browser datatype.
In order to do so I'm having to duplicate FolderBrowserService and modify it for my needs. The problem I'm having is that ThumbnailProvidersResolver is a internal sealed class, so obviously I can't access it.
Currently, I'm using the FolderBrowserService source from 6.1, but I can see that it's being rewritten for 6.1.2. With the 6.1.2 source I'm having issues with the UmbracoEntity type.
Looking for suggestions, and I prefer not to have to download and modify the core directly.
Thanks,
Dan
Working code with the ThumbnailProvidersResolver part commented out.
usingPike.Web.Trees.CustomMediaTree;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web.Script.Serialization;usingumbraco.BusinessLogic;usingumbraco.cms.businesslogic.Tags;usingUmbraco.Core.IO;usingUmbraco.Core.Media;usingUmbraco.Core.ObjectResolution;usingUmbraco.Web.BaseRest;namespacePike.Web.WebServices{//TODO: Can we convert this to MVC please instead of /base? [RestExtension("CustomFolderBrowserService")]publicclassCustomFolderBrowserService{ [RestExtensionMethod(ReturnXml = false)]publicstaticstringGetChildren(intparentId){varparentMedia=newglobal::umbraco.cms.businesslogic.media.Media(parentId);varcurrentUser=User.GetCurrent();vardata=newList<object>();// Check user is logged inif(currentUser==null)thrownewUnauthorizedAccessException("You must be logged in to use this service");// Check user is allowed to access selected media itemif(!(","+parentMedia.Path+",").Contains(","+currentUser.StartMediaId+","))thrownewUnauthorizedAccessException("You do not have access to this Media node");// Get children and filter//TODO: Only fetch files, not containers//TODO: Cache responses to speed up susequent searchesList<global::umbraco.cms.businesslogic.media.Media>children;if(parentId==-1&&Config.Instance.ConfigEntries.Any(a=>a.Users.Contains(currentUser.Id))){varallowedNodes=Config.Instance.ConfigEntries.First(a=>a.Users.Contains(currentUser.Id)).Nodes.Keys;children=newList<global::umbraco.cms.businesslogic.media.Media>();foreach(varnodeinallowedNodes){children.Add(newglobal::umbraco.cms.businesslogic.media.Media(node));}}else{children=parentMedia.Children.ToList();}foreach(varchildinchildren){varfileProp=child.getProperty("umbracoFile")??child.GenericProperties.FirstOrDefault(x=>x.PropertyType.DataTypeDefinition.DataType.Id==newGuid("5032a6e6-69e3-491d-bb28-cd31cd11086c"));varfileUrl=fileProp!=null?fileProp.Value.ToString():"";// ARGG!!! MAYBE LOOK AT WHAT DAMP IS DOING FOR THE DIALOG IMAGESvarthumbUrl="";// ThumbnailProvidersResolver.Current.GetThumbnailUrl(fileUrl);varitem=new{Id=child.Id,Path=child.Path,Name=child.Text,Tags=string.Join(",",Tag.GetTags(child.Id).Select(x=>x.TagCaption)),MediaTypeAlias=child.ContentType.Alias,EditUrl=string.Format("editMedia.aspx?id={0}",child.Id),FileUrl=fileUrl,ThumbnailUrl=!string.IsNullOrEmpty(thumbUrl)?thumbUrl:IOHelper.ResolveUrl(SystemDirectories.Umbraco+"/images/thumbnails/"+child.ContentType.Thumbnail)};data.Add(item);}returnnewJavaScriptSerializer().Serialize(data);} [RestExtensionMethod(ReturnXml = false)]publicstaticstringDelete(stringnodeIds){varnodeIdParts=nodeIds.Split(',');foreach(varnodeIdPartinnodeIdParts.Where(x=>!string.IsNullOrEmpty(x))){varnodeId=0;if(!Int32.TryParse(nodeIdPart,outnodeId))continue;varnode=newglobal::umbraco.cms.businesslogic.media.Media(nodeId);node.delete((","+node.Path+",").Contains(",-21,"));}returnnewJavaScriptSerializer().Serialize(new{success=true});}}
Got it working, but not pretty. Switched out EntityService for MediaService and ThumbnailProvidersResolver for TryGetThumbnailUrl (copied over the code).
How to use UmbracoEntity & ThumbnailProvidersResolver?
Hi,
I'm trying to customize some things in the media Folder Browser datatype.
In order to do so I'm having to duplicate FolderBrowserService and modify it for my needs. The problem I'm having is that ThumbnailProvidersResolver is a internal sealed class, so obviously I can't access it.
Currently, I'm using the FolderBrowserService source from 6.1, but I can see that it's being rewritten for 6.1.2. With the 6.1.2 source I'm having issues with the UmbracoEntity type.
Looking for suggestions, and I prefer not to have to download and modify the core directly.
Thanks,
Dan
Working code with the ThumbnailProvidersResolver part commented out.
Got it working, but not pretty. Switched out EntityService for MediaService and ThumbnailProvidersResolver for TryGetThumbnailUrl (copied over the code).
is working on a reply...