public static string GetPropertyAsMediaItem(this IPublishedContent content, string field)
        {
            if (string.IsNullOrEmpty(content.GetPropertyValue <string>(field)) == false)
            {
                var mItem = new umbraco.cms.businesslogic.media.Media(int.Parse(content.GetPropertyValue <string>(field)));

                var propertyValue = string.Empty;
                var property      = mItem.getProperty("umbracoFile");
                if (property != null)
                {
                    propertyValue = property.Value.ToString();
                }

                return(propertyValue);
            }
            return(string.Empty);
        }
示例#2
0
        public static void refreshMediaSection(int umbracoMediaId)
        {
            if (umbracoMediaId < 1000)
            {
                return;
            }
            var m = new umbraco.cms.businesslogic.media.Media(umbracoMediaId);

            if (m == null)
            {
                return;
            }

            // Voer wat Umbraco UI opties uit
            if (umbraco.BasePages.BasePage.Current != null)
            {
                // Ververs media tree
                string path, url;

                var p = m.getProperty(Constants.UmbracoPropertyAliasStatus);
                if (p != null && (p.Value as String) == "Original")
                {
                    path = m.Parent.Path;
                    url  = "editMedia.aspx?id=" + m.ParentId.ToString();
                }
                else
                {
                    path = m.Path;
                    url  = "editMedia.aspx?id=" + m.Id.ToString();
                }

                // Ververs de tree aan de linker kant (in de media section
                refreshMediaTree(path);

                // Open media node
                string script = String.Format(umbraco.BasePages.ClientTools.Scripts.ChangeContentFrameUrl(url));
                System.Web.UI.ScriptManager.RegisterStartupScript(umbraco.BasePages.BasePage.Current, umbraco.BasePages.BasePage.Current.GetType(), "showMediaId", script, true);
            }
        }
        public static string GetPropertyAsMediaItem(this IPublishedContent content, string field)
        {
            if (string.IsNullOrEmpty(content.GetPropertyValue<string>(field)) == false)
            {
                var mItem = new umbraco.cms.businesslogic.media.Media(int.Parse(content.GetPropertyValue<string>(field)));

                var propertyValue = string.Empty;
                var property = mItem.getProperty("umbracoFile");
                if (property != null)
                    propertyValue = property.Value.ToString();

                return propertyValue;
            }
            return string.Empty;
        }