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 ?? ""); }