Copied to clipboard

Flag this post as spam?

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


  • Sebastian Dammark 581 posts 1385 karma points
    May 05, 2011 @ 23:07
    Sebastian Dammark
    0

    How to make cropping work ?

    Can anyone tell me how to make image cropping work with DAMP ?
    http://damp.codeplex.com/SourceControl/changeset/changes/72398

    I have a regular Media with the Image Cropper datatype attached.

    On my document I then use DAMP as my picker, but the crops are still not created unless I hit Save twice in the media section.

    What am I doing wrong ?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    May 06, 2011 @ 10:17
    Jeroen Breuer
    0

    Hello,

    As it says in the comment it's a helper method. This means you need to call the method yourself. Here is a sample you can use in the media before save event:

    try
    {
        propUmbracoFile = sender.GetPropery("umbracoFile");
        if (propUmbracoFile != null && (propUmbracoFile.Value != null ||          !string.IsNullOrEmpty(propUmbracoFile.Value.ToString()))
        {
            //Crop the images automatically without having to press the save button first.
            DAMP_Helper.CallImagecropper(sender.Id);
        }
    }
    catch (Exception ex)
    {
        LogException(ex);
    }

    The above code is a sample if you use the umbracoFile upload field for cropping. This before save event also works without using DAMP as a media picker. I could add this code into DAMP as well, but I had a little discussion about this. Here are the e-mails:

    Email 1:

    DAMP now has a helper to call the image cropper so you don't need to press the save button, but currently this is only a helper and you need to manually programm the before save event and call it in there. Should I include the before save event in the code? This would mean the image cropper would always be called (only if it's empty) in the before save event. Is this a good idea or should I leave this choice to the developers? I don't think it would hurt if I also included the before save event. 

    Email 2:

    Ok I already ran into a problem where the DAMP events are fired before my own events and I can only call the image cropper helper method after my own events are fired. So I guess it's best to let the developer call the image cropper helper method himself instead of already implementing it in the DAMP before save event :).

    It's recommended to use the latest change set since I already added some improvements to the CallImageCropper method, however this new version is still in development so there are still some bugs.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft