Copied to clipboard

Flag this post as spam?

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


  • Martin 81 posts 246 karma points
    Aug 22, 2016 @ 11:26
    Martin
    0

    Getting back up to speed with Ditto

    Hi Lee,

    The last time I used Ditto I think it hadn't even hit 0.5 and I know there have been some serious changes since then.

    Let's say I have a node that has a standard Umbraco Image Cropper against it, is there anything out of the box that will allow me to handle the mapping or do I need a custom Type Converter / Value Resolver?

    If a custom converter is required could you please give me an example?

    Cheers, Martin

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Aug 22, 2016 @ 11:35
    Lee Kelleher
    100

    Hi Martin,

    Sure, see this thread:

    https://our.umbraco.org/projects/developer-tools/ditto/ditto-feedback/66353-imagecropper-mapping-with-ditto#comment-221601

    We have a unit-test that supports this:
    https://github.com/leekelleher/umbraco-ditto/blob/master/tests/Our.Umbraco.Ditto.Tests/ImageCropDataSetMappingTests.cs
    But it does need the ImageCropperPropertyConverter that Jeavon provides in the comments of the above thread.

    Cheers,
    - Lee

  • James Jackson-South 489 posts 1747 karma points c-trib
    Aug 24, 2016 @ 06:41
    James Jackson-South
    1

    Hey Lee, Just to note as of Umbraco 7.4.3 I think the ImageCropperPropertyConverter exists in Core

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Aug 24, 2016 @ 08:04
    Lee Kelleher
    0

    You're right! It got added in v7.4.0, ImageCropperValueConverter. #TIL ;-)

    Cheers,
    - Lee

  • Martin 81 posts 246 karma points
    Aug 24, 2016 @ 16:30
    Martin
    0

    Nice! I just removed the converter from my solution and everything still works :))

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Aug 25, 2016 @ 08:38
    Lee Kelleher
    0

    Cool! Glad that it worked out. Do you still need to save the crop first though? (just asking for future reference)

  • Martin 81 posts 246 karma points
    Aug 22, 2016 @ 13:49
    Martin
    0

    Hi Lee, thanks for the response. So how do I go about using the value converter?

    I have a 'section' document type which has the two image cropper properties 'sectionImageOne' and 'sectionImageTwo' and then on my model I have those two as properties of type 'ImageCropDataSet'. What do I do to tell Ditto to use that converter?

    Martin

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Aug 22, 2016 @ 16:25
    Lee Kelleher
    0

    If you add the ImageCropperPropertyConverter class in your code (and compile), then Umbraco will pick it up and give the correct type to Ditto. No other attributes need to be declared.

  • Martin 81 posts 246 karma points
    Aug 22, 2016 @ 17:14
    Martin
    0

    Hmm I've done that and get a null exception when ditto tries to do the mapping in my hijack controller. Everything works when I comment out those two 'ImageCropDataSet' properties on my model.

    Maybe it's worth noting that I haven't defined any crops for the image cropper and some of the croppers haven't yet had an image added to them. At the moment I mainly want to use the cropper to get the focal point stuff and then manipulate the crops using querystring parameters.

  • Martin 81 posts 246 karma points
    Aug 22, 2016 @ 17:30
    Martin
    0

    Ok, so I added a square 300 x 300 crop to the image cropper and it works now. Would it not be possible for it to work without any crops defined as in my case I'm using the cropper for the ability to set a focal point although I guess in future I may set predefined crops against the image. It just seems annoying to have to set one now as that 300px crop is never gonna get used

  • James Jackson-South 489 posts 1747 karma points c-trib
    Aug 24, 2016 @ 06:44
    James Jackson-South
    1

    Hi Martin,

    GetCropUrl() relies on having an alias so we can't do anything about that. The only url available to you without one will be the ImageCropDataSet.Src property

    Cheers James

Please Sign in or register to post replies

Write your reply to:

Draft