Copied to clipboard

Flag this post as spam?

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


  • Daniel Palm 36 posts 148 karma points
    Apr 07, 2015 @ 16:13
    Daniel Palm
    0

    Getting the Src and Crop when using Image Cropper

    I have a Image Cropper datatype setup with one Crop ("Promo"), in Umbraco 7.2.4. I can get the image with this code:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @foreach(var item in Umbraco.Content(1071).Children("Promo").Where("Visible"){
    var image = item.promoBild;
    var cropUrl = image.GetCropUrl("promoBild", "Promo");
    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-6 sod-promo">
    <img src="@cropUrl" />
    <h2>item.promoRubrik</h2>
    <p>item.promoText</p>
    <p><a href="item.promoLank">Läs mer</a></p>
    </div>
    }

    But I can´t get the image with the crop. 

    Observe that I have a doctype called Promo as well. Yes I know, sorry. promoBild is the name of the Image Cropper.

     

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Apr 07, 2015 @ 19:53
    Jeavon Leopold
    0

    Hi Daniel,

    This looks fine, have you checked the alias of the crop is "Promo"?

    Jeavon

  • Daniel Palm 36 posts 148 karma points
    Apr 07, 2015 @ 22:12
    Daniel Palm
    0

    Yes, the crop alias is Promo.

    Actually, I can get the image with this code:

    var image = item.promoBild;
    <img src="@image.src" />

    If I try to add  the cropUrl, like this:

    var image = item.promoBild;
    var cropUrl = image.GetCropUrl("promoBild","Promo");
    <img src="@cropUrl" /> 

    I get an "Error loading Partial View script" error.

    The Json code looks like this:

    {
     "focalPoint": {
       "left": 0.5025,
       "top": 0.66
     },
     "src": "/media/1003/fest.jpg",
     "crops": [
       {
        "alias": "Promo",
        "width": 300,
       "height": 169
     }
    ]
    }

     

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Apr 07, 2015 @ 23:11
    Jeavon Leopold
    100

    Ah, I think it should be item.GetCropUrl?

  • Daniel Palm 36 posts 148 karma points
    Apr 07, 2015 @ 23:15
    Daniel Palm
    0

    That works. Thanks a lot! 

     

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Apr 07, 2015 @ 23:20
    Jeavon Leopold
    0

    Great!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies