Copied to clipboard

Flag this post as spam?

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


  • Jon 38 posts 157 karma points
    Jan 29, 2015 @ 14:54
    Jon
    0

    Getting the uncropped image from an image cropper?

    I need to get the uncropped version of an image from the image cropper. I can't seem to find a way to achieve this but presumably it's possible?

    My objects are typed so I need to know how to get them that way.

    Cheers

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 29, 2015 @ 14:57
    Jeavon Leopold
    0

    Hi Jon,

    Are you using a media, content or member item?

    Also what is the name of your cropper property alias?

    Jeavon

  • Jon 38 posts 157 karma points
    Jan 29, 2015 @ 15:01
    Jon
    0

    Hi Jeavon,

    I'm not sure what you mean by media, content or member item. Can you elaborate and apologies for my noobiness!

    Here's how I'm getting my thumbnail crop:

    @photo.GetCropUrl("image", "thumbnail")

    Jon

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 29, 2015 @ 15:15
    Jeavon Leopold
    0

    No worries, show me how you set @photo

  • Jon 38 posts 157 karma points
    Jan 29, 2015 @ 15:24
    Jon
    0

    It gets set in a loop of items:

    foreach (IPublishedContent photo in photoGallery.Children<IPublishedContent>())
    {

    }

    Each of the children represents a photo and has the image cropper property "image" on it.

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 29, 2015 @ 15:35
    Jeavon Leopold
    100

    Ok, then you will need to deserialise the object like this:

    @using Newtonsoft.Json
    @using Umbraco.Web.Models
    
    @{
      var imageCrops = JsonConvert.DeserializeObject<ImageCropDataSet>(photo.GetPropertyValue<string>("image"));
      var orgianlMedia = imageCrops.Src;
    }
    

    Jeavon

  • Jon 38 posts 157 karma points
    Jan 29, 2015 @ 15:40
    Jon
    0

    Works perfectly Jeavon, thanks!

    In the interests of keeping my Razor tidy it would be nice if this was accessible through the normal API but hey ho. It works.

    Cheers,
    Jon

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 29, 2015 @ 15:43
    Jeavon Leopold
    0

    Yeah this little cheat also came to me:

        var orginalMediaCheat = (string)photo.AsDynamic().image.src;
    
  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 29, 2015 @ 15:45
    Jeavon Leopold
    0

    I have been wondering about adding a image cropper converter to my Value Converters package so that they would always return ImageCropDataSet, I would also need to add an extension method for GetCropUrl.

    Thinking about it....

  • Jon 38 posts 157 karma points
    Jan 29, 2015 @ 16:19
    Jon
    0

    I have your value convertors installed and they're a huge help in keeping things tidy. Adding in support for the Image Cropper would get a thumbs up from me!

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 29, 2015 @ 19:43
    Jeavon Leopold
    0

    Ah great to hear! Could you please mark the correct answer in this thread as it's helpful to others searching for the same thing.

Please Sign in or register to post replies

Write your reply to:

Draft