Copied to clipboard

Flag this post as spam?

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


  • Bruno Olsen 75 posts 316 karma points
    Jun 01, 2016 @ 11:23
    Bruno Olsen
    0

    This should be very simple, and yet I seem to run into the same wall all the time. There are many examples, but why can't I get them to work??? Well, here goes:

                 <img src="@Model.Content.GetCropUrl("billedeBoks1", "Forsidebokse")" />
    
                  <img src="@Model.Content.GetCropUrl(propertyAlias:"billedeBoks1", width:300, height:100)" />
    
                  <img src="@Url.GetCropUrl(Model.Content, "billedeBoks1", "Forsidebokse")" />
    

    These are three examples I've found that should output the url for the image - first and third with crop data. However, the output is as follows:

                  <img src="1069?mode=pad&amp;rnd=131092595600000000" />
    
                  <img src="1069?mode=pad&amp;width=300&amp;height=100&amp;rnd=131092595600000000" />
    
                  <img src="1069?mode=pad&amp;rnd=131092595600000000" />
    

    Now, the 1069 is the right id for the selected image. What am I missing??? Pretty sure it's omething obvious, but in my searches around the web no hits explains why I can't get it to work.

    Can anyone help?

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Jun 01, 2016 @ 13:36
    Paul Seal
    0

    I would just type in the query strings myself

              <img src="/media/11244/1069.jpg?width=600&height=300&mode=crop&anchor=center" />
    
  • Jordan 24 posts 182 karma points
    Jun 01, 2016 @ 14:33
    Jordan
    0

    Hey Bruno,

    I had this happen to me as well, took me for ever to figure this out, when I was working with it. I believe your problem is you are not defining the page it is stored/coming from.

    for instant if the crop part of the url is happening in the media section, you have to access the Media content before grabbing the crop.

     Url.GetCropUrl(node image is stored against, "Alias name for the cropper", "Crop type alias setup against the cropper")
    

    This may not be your problem, but I hope it helps.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jun 01, 2016 @ 16:33
    Jeavon Leopold
    100

    Hi Bruno,

    I think it is because you have a media picker, first you need to get the media item from the picker, then the crop.

    e.g.

    @{
        var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("billedeBoks1"));
    }
    <img src="@mediaItem.GetCropUrl("Forsidebokse")" />
    

    Or with Umbraco v7.4+ using the UrlHelper it would be:

    @{
        var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("billedeBoks1"));
    }
    <img src="@Url.GetCropUrl(mediaItem, "Forsidebokse")" />
    

    I hope that helps you work it out?

    Jeavon

  • Bruno Olsen 75 posts 316 karma points
    Jun 02, 2016 @ 06:29
    Bruno Olsen
    0

    Hi Jeavon

    That did indeed make a difference :)

    By renaming the mediaItem variable in your example I got it working.

    Thanks for your help :)

    And thank you Paul and Jordan for wanting to help :)

    /Bruno

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jun 02, 2016 @ 07:03
    Jeavon Leopold
    0

    Hi Bruno,

    Great it's working for you, I hope you understand now why it wasn't before?

    I'm not sure I understand what you mean about renaming mediaItem?

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft