oohnajra

UmbracoHelper.cshtml

Jul 16th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. @using umbraco.MacroEngines;
  2. @using System.Xml;
  3.  
  4. @functions {
  5. public static string GetMediaCropperUrl(object crops, string cropName)
  6. {
  7. string cropUrl = string.Empty;
  8.  
  9. if (crops.GetType() == typeof(DynamicXml))
  10. {
  11. DynamicXml cropsXml = (DynamicXml)crops;
  12.  
  13. XmlDocument xmlDocument = new XmlDocument();
  14. xmlDocument.LoadXml(cropsXml.BaseElement.ToString());
  15. XmlNode cropNode = xmlDocument.SelectSingleNode("descendant::crops/crop[@name='" + cropName + "']");
  16.  
  17. if (cropNode != null)
  18. {
  19. cropUrl = cropNode.Attributes.GetNamedItem("url").InnerText;
  20. }
  21. }
  22.  
  23. return cropUrl;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment