Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mathias Valentin 60 posts 208 karma points
    May 30, 2013 @ 11:21
    Mathias Valentin
    0

    How to get image crop in .NET?

    In XSLT I do something like this:
    umbraco.library:GetMedia(propertyName, 0)/crops//crop [@name = 'cropName']/@url

    But how do I get a specific crop in a .NET user control? 

    /m

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    May 30, 2013 @ 12:13
    Alex Skrypnyk
    0

    Hello Mathias,

    You could use something like that:

    @usingSystem.Xml
    @functions{    
       
    publicstaticstringGetImageCropperUrl(string cropText,string cropName)
       
    {
           
    string cropUrl =string.Empty;

           
    XmlDocument xmlDocument =newXmlDocument();
            xmlDocument
    .LoadXml(cropText);
           
    XmlNode cropNode = xmlDocument.SelectSingleNode("descendant::crops/crop[@name='"+ cropName +"']");

           
    if(cropNode !=null)
           
    {
                cropUrl
    = cropNode.Attributes.GetNamedItem("url").InnerText;
           
    }

           
    return cropUrl;
       
    }
    }
  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    May 30, 2013 @ 12:33
  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    May 30, 2013 @ 13:03
    Alex Skrypnyk
    0

    Very good article about Images in Umbraco:
    http://24days.in/umbraco/2012/introducing-the-umbraco-image-control/ 

  • Mathias Valentin 60 posts 208 karma points
    May 30, 2013 @ 14:35
    Mathias Valentin
    0

    Thanks Alex! Couldn't find any documentation on this. So this is just what I needed! I'll try it out later.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies