Copied to clipboard

Flag this post as spam?

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


  • Gert 81 posts 288 karma points
    Feb 17, 2015 @ 14:39
    Gert
    0

    Is there a way to get an image cropper property recursively

    Hi, I have an image cropper property for displaying a banner image and I want to use this property recursively so that I only need to upload an image on the parent page and the child pages can automatically take the cropped image from the parent page if there is no image uploaded on the child page.

    Is this possible?

    e.g. instead of using

     <img src="@CurrentPage.GetCropUrl( "BannerImage", "carouselcrop" )" />
    

    it would be nice if there would also exist an overloaded method

    <img src="@CurrentPage.GetCropUrl( "BannerImage", "carouselcrop", recursive:true )" />
    

    Since this is not the case, how to solve this?

    Thanks!

    Kind Regards, Gert.

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Feb 17, 2015 @ 18:23
    Jeavon Leopold
    102

    Hi Gert,

    I think the below should work for you?

    @{
        var nodeWithCropper = Model.Content.AncestorsOrSelf().First(x => x.HasValue("BannerImage"));
    }
    <img src="@nodeWithCropper.GetCropUrl("BannerImage", "carouselcrop")"/>
    

    Jeavon

  • Gert 81 posts 288 karma points
    Feb 17, 2015 @ 18:44
    Gert
    0

    That did the trick. Thanks Jeavon!

    Regards, Gert.

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Feb 17, 2015 @ 19:35
    Jeavon Leopold
    0

    Great, you're welcome!

Please Sign in or register to post replies

Write your reply to:

Draft