Copied to clipboard

Flag this post as spam?

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


  • Proxicode 127 posts 323 karma points
    Aug 04, 2023 @ 15:48
    Proxicode
    0

    v12 GetCropUrl/ImageSharp

    Good day all!

    I have a new v12 site and am attempting to use the ImageCropper. I am following the docs from this page - https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/image-cropper#powered-by-imagesharp.web

    Whether I try

    <img src="@Url.GetCropUrl(Model.Photo,"cropName")" />
    

    or (preferred)

    <img src="@Url.GetCropUrl(Model.Photo, height: 300, width: 400)" alt="@Model.Photo.Name" />
    

    On render I get the modified URL as expected

    /media/n1nn3c0x/_d6a0369_copy.jpg?rxy=1,0&amp;width=400&amp;height=300&amp;v=1d9c546dc0ea470
    

    but no change to the image. It seems that the query string parameters are ignored. Should I need to do any of the

    app.UseImageSharp();
    or
    umbracoBuilder.AddUmbracoImageSharp();
    

    or should it "just work" out of the box? Does this have to do with the new licensing for ImageSharp?

    Happy to share more details if necessary.

    Thanks!

    -Roger

  • Justin Neville 22 posts 196 karma points c-trib
    Aug 08, 2023 @ 10:00
    Justin Neville
    100

    It should just work out of the box, can you check your URL is not HTML encoded?

    Try this in your address bar and see if it returns the processed image:

    /media/n1nn3c0x/_d6a0369_copy.jpg?rxy=1,0&width=400&height=300&v=1d9c546dc0ea470
    

    I don't know if the forum added the encoding or if that has come from your end?

    Even in it's simplest form, this should resize an image:

    /media/n1nn3c0x/_d6a0369_copy.jpg?width=400
    

    If that doesn't work, maybe check for any errors in the logs as Image Sharp should be added automatically by Umbraco.

  • Proxicode 127 posts 323 karma points
    Aug 08, 2023 @ 12:20
    Proxicode
    0

    Yep, you nailed it! Using your examples with non-encoded URLs works as expected! Not sure why they are being encoded in the first place (or why that didn't jump out at me), but that is absolutely the problem!

    Thanks Justin for helping me out on this H5YR!!

  • Proxicode 127 posts 323 karma points
    Aug 08, 2023 @ 12:33
    Proxicode
    0

    All good :-)

    var img = slide.Value<IPublishedContent>("slideImage");
    <img src="@Url.GetCropUrl(img, height: 300, width: 400, htmlEncode: false)" />
    
  • Justin Neville 22 posts 196 karma points c-trib
    Aug 08, 2023 @ 12:22
    Justin Neville
    0

    No problem, glad that was the answer!

Please Sign in or register to post replies

Write your reply to:

Draft