Copied to clipboard

Flag this post as spam?

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


  • Ron S. 3 posts 23 karma points
    Oct 18, 2013 @ 12:40
    Ron S.
    0

    Getting cropper values

    Dear Umbraco Users!

    For a project with a photo carousel I need to know the exact height of the returned crop (uComponents Cropper). So I was wondering if it is possible to get the height of the returned crop, since the cropper sends me some XML info about the original image size and the coordinats about the crop related to the original image. But not about the height of the returned crop.

    So I was wondering if this is possible by retrieving all the created crops, and their sizes?

    I am using Umbraco 6.1.5 and uComponents 5.4.2.1. 
    And ofcourse I am working in Razor (which is awesome btw)

    Any help is appreciated!

    Greets, Ron

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Nov 02, 2013 @ 13:38
    Jeavon Leopold
    0

    Hi Ron,

    Firstly, I'm assuming you mean the Core cropper rather than uComponents (I don't think there is one).

    There are some handy methods in uComponents developed for XSLT but they are equally helpful in Razor.

    Assuming you are using Razor Macros (rather than MVC) then I think this is what you are after?

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using uComponents.XsltExtensions;
    
    @{
      var mediaItem = Library.MediaById(1067);
      if (mediaItem.crops.Count() > 0)
      {
          var path = mediaItem.crops.Find("@name", "Thumb").url;
          var height = Media.GetImageHeight(path);
          var width = Media.GetImageWidth(path);
    
          <img src="@path" height="@height" width="@width" />      
      }
    }
    

    Note the @using uComponents.XsltExtensions;

    Also, I would highly recommend you use the Image Cropper Extended package instead of using the Core Cropper as it is a much improved and fixed version of what comes by default in Umbraco.

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft