public override object GetData(ITabContext context) { var plugin = Plugin.Create("Function", "Param", "Type"); try { string url = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; int NodeId = -1; if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request["glimpse7GetMediaById"])) { Int32.TryParse(System.Web.HttpContext.Current.Request["glimpse7GetMediaById"], out NodeId); } if (NodeId > 0) { dynamic mediaItem = new DynamicMedia(NodeId); return(UmbracoFn.showMethodsValue(mediaItem, "media")); } else { return(UmbracoFn.showMethods(typeof(DynamicMedia))); } } catch (Exception ex) { plugin.AddRow().Column(ex.ToString()); } return(plugin); }
private string getImageUrlFromMediaItem(string mediaId) { if (String.IsNullOrWhiteSpace(mediaId)) { return(String.Empty); } dynamic mediaItem = new DynamicMedia(mediaId); return(mediaItem.umbracoFile); }
private static string ImageUrlFromMediaItem(RazorLibraryCore ctx, int mediaId, string cropProperty, string cropName) { string url = null; DynamicMedia media = ctx.MediaById(mediaId); if (media != null) { if (media.HasProperty(cropProperty)) { dynamic d = new DynamicXml(media.GetPropertyValue(cropProperty)).Find("@name", cropName); url = (string)d.url; } if (string.IsNullOrWhiteSpace(url) && media.HasValue("umbracoFile")) { url = media.GetPropertyValue("umbracoFile"); } } return(url ?? ""); }
private string GetFullMediaPath(int mediaId) { string mediaPath = string.Empty; DynamicMedia media = new DynamicMedia(mediaId); string mediaNiceUrl = media.NiceUrl; if (!string.IsNullOrEmpty(mediaNiceUrl)) { dynamic mediaVal = null; try { mediaVal = System.Web.Helpers.Json.Decode(mediaNiceUrl); mediaNiceUrl = mediaVal.src; } catch (Exception ex) { //When can't decode -> ignored LogHelper.Error <string>("Can't decode the media while uploading", ex); } } mediaPath = string.Format("{0}{1}", HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority), mediaNiceUrl); return(mediaPath); }
// when a user selected a node from the dynamic tree private void tree_selected(TreeModel model, TreeIter iter) { selected = (DynamicMedia) model.GetValue (iter, 0); selected.LoadMedia (); }
// we will only auto generate where no folders already exist // in other words only do this once and don't over write any changes the user may have made private bool folderHasNoChildren(IMedia media) { var mediaNode = new DynamicMedia(media.Id); return(mediaNode.Children.Count() == 0); }