Copied to clipboard

Flag this post as spam?

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


  • Mark Mitchell 35 posts 60 karma points
    Feb 05, 2011 @ 02:05
    Mark Mitchell
    0

    Using an Image Cropper in a Document Type

    Hello,

    I would like to use an Image Cropper as a property in one of my Document Types.  I have created a Media Picker property that selects the image that I want to crop, and then I added a new Image Cropper datatype that has the 'Property Alias' set to the alias of my Media Picker property. I then added the my new Image Cropper datatype as another property in my Document Type settings directly below the Media Picker it is tied to.

    When I then go to my Content section and select a node of this document type, I see the media picker and the empty Image Cropper. So far, so good, but as soon as I select an image with my media picker and save the node, I get the error:

    [ArgumentException: The relative virtual path '1090' is not allowed here.]
       System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +11416550
    

     

    Any ideas on how I can make this work, or is this an unsupported way of using the Image Cropper.

    I would much rather have the content editors select their crop rectangle in the document where the image will be used, as opposed to in the Media section like they do in the Image Cropper tutorial video.

    Thanks!

     

  • Mike Chambers 636 posts 1253 karma points c-trib
    Feb 05, 2011 @ 10:41
    Mike Chambers
    0

    Not actually used the image cropper, but looks like it's after a url as the input for the media location...

    You might need to use

     umbraco.library:GetMedia(id, deep)/umbracoFile

    or if c# required

    umbraco.cms.businesslogic.media.Media mediaXP = new umbraco.cms.businesslogic.media.Media(Id));

    string url = mediaXP.getProperty("umbracoFile").Value.ToString();

  • Mark Mitchell 35 posts 60 karma points
    Feb 05, 2011 @ 16:43
    Mark Mitchell
    0

    I was eventually able to get it to work by changing my media picker to an upload control. It seems the cropper control is not compatible with the media picker set as the source.  Not sure if you can apply some code into the cropper's 'Property Alias' field instead of a simple alias though, I did not try that.

    However the c# snippet you posted is exactly what I needed to figure out how to work with the media once it was uploaded in the Razor macro.

    Thanks!

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 16, 2011 @ 12:36
    Hendy Racher
    1

    Hi Mark,

    FYI in uQuery there are helper extension methods on the Media and Node objects to return the urls for specific crops:

    using uComponents.Core.uQueryExtensions;

    Node node = new Node(123);
    string url = node.GetImageCropperUrl("cropperPropertyAlias", "cropAlias");

    HTH,

    Hendy

Please Sign in or register to post replies

Write your reply to:

Draft