Copied to clipboard

Flag this post as spam?

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


  • Paul Lagmark 65 posts 140 karma points
    May 06, 2015 @ 11:35
    Paul Lagmark
    0

    Getting cropped image from node

    Hi,

    I have made a slider that is constructed like this:

    Slides
    - Slide 1
    - Slide 2

    In Slide 1 and Slide 2 I use a media picker that I configured to use the Image Cropper datatype. I works fine in the back-office but I can't manage to render the image in my markup. I've tried many things but this is how I ended up for now:

    var slides = Umbraco.Content(1244).Children;

    <div id="owl-example" class="owl-carousel">

            @foreach (var slide in slides)
            {
                var bild = Umbraco.Media(slide.Bild);
                <div>
                    <img src="@slide.GetCropUrl("bild")"  />
                    <br />
                    <br />
                    <h3>@slide.Titel</h3>
                    <p>@slide.Text</p>
                </div>
            }
    </div>

    Why can't i get the image as I did before when it was not cropped?



  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 06, 2015 @ 11:42
    Dennis Aaen
    0

    Hi Paul and welcoeme to our :), 

    Have you seen the documentation about how to use the image cropper, I think would help you https://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Image-Cropper 

    In addition to this documentation I would also recommend you to watch this https://www.youtube.com/watch?v=bQsvGmnYaUU episode from uHangout where Jeavon explains how the image cropper is working.

    Hope this helps,

    /Dennis

     

     

     

  • Paul Lagmark 65 posts 140 karma points
    May 06, 2015 @ 11:44
    Paul Lagmark
    0

    Thank you Dennis Aaen! :)

    I will check the links out, thanks.

    I will write here when I find the solution to my problem as I think there is other people out there that need a clear answer to this question. :) 

  • Paul Lagmark 65 posts 140 karma points
    May 06, 2015 @ 12:00
    Paul Lagmark
    0

    This line works for me:



    I think its a little bit strange that this do not work:

     var slides = Umbraco.Content(1244).Children;

     

            @foreach (var slide in slides)
            {

    }

     

    To me the "slide" variable in the foreach-loop is a node that contains the cropped image in the same way that the node i get from "@Umbraco.Content(1245)"

    What am I missing? 

    ANSWER:

    I had a variable that was getting it's value from a node that did not exist anymore in my markup, thats why the markup failed to render.

    <img src="@slide.GetCropUrl("image", "slide")" /> works fine. 

  • 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