private static string ImageUrlFromXml(RazorLibraryCore ctx, DynamicXml media, string cropProperty, string cropName) { string url = null; if (media != null) { var crop = new DynamicXml(media.DescendantsOrSelf(x => x.Name == cropProperty).FirstOrDefault().ToXml()); try { if (crop != null) { dynamic c = crop.Find("@name", cropName); url = (string)c.url; } } catch { } if (string.IsNullOrWhiteSpace(url)) { var f = media.Descendants(x => x.Name == "umbracoFile").FirstOrDefault(); if (f != null) { url = f.InnerText; } } } return(url ?? ""); }