Copied to clipboard

Flag this post as spam?

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


  • Mark 6 posts 74 karma points
    Aug 07, 2019 @ 19:07
    Mark
    0

    GetCropUrl Returns Only the Url Paramaters for Azure Blob Storage Images

    Hi,

    I have a 7.15.1 install and I've gone through all the steps to setup Azure storage with these instructions.

    I'm using the Image Cropper data type to add an image to my content with 4 different crops. Everything seems to work. It creates 2 files in my azure storage one with the name of the file and one with the name of the file _thumb.

    The problem is that when I use Image.GetUrlCrop("mycropname") it only returns the url params, for example,

    "?anchor=center&mode=crop&width=250&height=150"

    If I use just Image.ToHtmlString(), then the image works but it's not cropped, and the image appears to be coming from Azure.

    Does anyone have any suggestions on what I might be doing wrong?

    I'm not using a CDN, do I have to do that?

    Thank you for your help!

  • Mark 6 posts 74 karma points
    Aug 16, 2019 @ 17:32
    Mark
    0

    Just in case anyone has the same issue. The way I fixed my problem was to piece together the correct url to remote.axd to get the image to work.

    It needs to look like (I have my localhost in there, but yours will be different):

    /remote.axd?http://localhost:50677/media/1003/myimage.jpg?center=0.34,0.464&mode=crop&width=250&height=150
    

    So to do this I put together the path to the image file without the domain:

    var image = item.Image.ToHtmlString() + item.Image.GetCropUrl("MediumBanner");
    

    This gets: /media/1003/myimage.jpg?center=0.34,0.464&mode=crop&width=250&height=150

    Then I just needed to add in the domain, the port (in my case for local), and the reference to "/remote.axd?"

    image = "/remote.axd?" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + image;
    

    There's a lot better way to do that last step, but that's the general idea. Also, another way is to do a URL rewrite which is probably a lot faster. However, it was helpful for me to build this url myself so that I understood what's going on.

  • SteveV 54 posts 240 karma points
    Aug 17, 2019 @ 10:13
    SteveV
    0

    What type is Image in your code and how do you retrieve it's value from the model?

  • Mark 6 posts 74 karma points
    Aug 22, 2019 @ 12:22
    Mark
    0

    The Image is an Image Cropper data type, it's an element in my IPublishedContent Doc Type which I'm referring to as "item" up above.

  • Frans de Jong 550 posts 1862 karma points MVP 4x c-trib
    Aug 28, 2019 @ 11:48
    Frans de Jong
    0

    If you want the full Url you need to get it trough the UrlHelper:

    Url.GetCropUrl(item.Image, "MediumBanner")
    
Please Sign in or register to post replies

Write your reply to:

Draft