Copied to clipboard

Flag this post as spam?

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


  • Pierre Thevenet 8 posts 79 karma points
    Jul 25, 2022 @ 10:40
    Pierre Thevenet
    0

    GetCropUrl doesn't resize the image on Umbraco 10

    Hi,

    I migrated from Umbraco 9 to Umbraco 10 and I think everything run fine but ImageSharp which doesn't want to resize my images.

    My code is as follow:

    image.GetCropUrl(width: 600, height:400, quality:80, furtherOptions: "&format=webp")

    but the resulted image is neither resized/cropped nor rended in a webp format.

    Do you have any idea where it can come from (probably a mis configuration somewhere, but I can't find it).

    Thanks

  • Ambert van Unen 175 posts 817 karma points c-trib
    Jul 25, 2022 @ 11:31
    Ambert van Unen
    0

    Is image an MediaWithCrops?

    If so, it should work (have the same example right infront of me : @newsItem.Image.GetCropUrl(400,400, furtherOptions:"&format=WebP"))

    Could you post the URL that is visible in the frontend ? (the parameters).

    I've had some issues with this, but only when getting the actual crop from an alias (had to reselect the cropped area). Not directly of an selected Image..

  • Pierre Thevenet 8 posts 79 karma points
    Jul 25, 2022 @ 12:43
    Pierre Thevenet
    0

    image is indeed a MediaWithCrops object

    The created url is as follow:

    /media/trxbtnzn/my-image.jpg?width=600&height=400&quality=80&format=webp&rnd=132925045782200000

    the image appears correctly, but is not cropped as expected

  • Maksim Bogunović 1 post 71 karma points
    Jul 25, 2022 @ 13:58
    Maksim Bogunović
    0

    Hi Pierre, did you check documentatino for WebP Image Support?

    It mentions a few things you can check like (imageprocessor version in umbraco10, msvcr123.dll on your localhost/production server, etc.): https://imageprocessor.org/imageprocessor/plugins/webp/

  • Pierre Thevenet 8 posts 79 karma points
    Jul 25, 2022 @ 14:05
    Pierre Thevenet
    0

    I don't think it has to do with the webp format. I also tried without the webp extension and got the same issue (well without the formation conversion issue as it was not requested)

  • Ambert van Unen 175 posts 817 karma points c-trib
    Jul 25, 2022 @ 15:09
    Ambert van Unen
    0

    Is this online? And are you using a blobstorage? If so the configuration could be bad of your blob.

  • Pierre Thevenet 8 posts 79 karma points
    Jul 25, 2022 @ 15:10
    Pierre Thevenet
    0

    It is indeed online, I have both the issue on my dev server and pre production server. Both use different azure blob storage

  • Ambert van Unen 175 posts 817 karma points c-trib
    Jul 25, 2022 @ 15:26
    Ambert van Unen
    0

    Then it is most likely something to have to do with the cache settings in your connectionstring.

    To be 100% sure you could try running it locally, but I can almost guarantee it's a Blob connectionstring issue.

  • Pierre Thevenet 8 posts 79 karma points
    Jul 25, 2022 @ 15:43
    Pierre Thevenet
    0

    I remove the azure blob configuration from the appsetting and the .AddAzureBlobMediaFileSystem() from the ConfigureServices and all my images went broken (so far so good)

    I added a new image via the back office of umbraco and tried again and... the new image is not cropped either :'(

    I probably missed something somewhere

  • Pierre Thevenet 8 posts 79 karma points
    Jul 26, 2022 @ 09:00
    Pierre Thevenet
    0

    So I tried to change some configuration and nothing worked.

    So I made a clean install of umbraco and literally copy/pasted the content of the Startup.cs file in my project and now the ImageSharp crops works like a charm.

    It seems that I broke something with my modifications in the Startup.cs file, I will keep posted when I find what was the exact issue.

    Thank you for your help guys

  • Pierre Thevenet 8 posts 79 karma points
    Jul 26, 2022 @ 09:37
    Pierre Thevenet
    1

    For anyone encountering the same issue, I used app.UseStaticFiles() which bypassed the ImageSharp crop and resize.

    I removed the line in my Startup.cs Configure and it worked like a charm

  • Ambert van Unen 175 posts 817 karma points c-trib
    Jul 26, 2022 @ 10:01
    Ambert van Unen
    0

    Hah I was just searching about what that method does.. Glad you found it already!

  • Rickard Lövgren 1 post 77 karma points
    Oct 11, 2022 @ 13:44
    Rickard Lövgren
    6

    To build on that for anyone else that encounters this.

    Today I encountered the same thing (Umbraco 10.2.1.7). The problem is I can't remove app.UseStaticFiles() since that is needed for some other functionality.

    When this happens you can simply bypass the /media/ folder by changing the configuration to:

    app.UseWhen(context => !context.Request.Path.StartsWithSegments("/media"),
                appBuilder => appBuilder.UseStaticFiles());
    
  • Sebastiaan Janssen 5053 posts 15507 karma points MVP admin hq
    Oct 11, 2022 @ 13:53
    Sebastiaan Janssen
    0

    Ooh that's a neat trick! Would you mind adding that as a comment to this thread as well please Rickard? 🙏

    https://our.umbraco.com/forum/using-umbraco-and-getting-started/109573-getcropurl-doesnt-resize-the-image-on-umbraco-10

  • David Zweben 266 posts 751 karma points
    Nov 02, 2022 @ 14:51
    David Zweben
    1

    @Rickard Lövgren

    This solved my issue! I had app.UseStaticFiles() in place to enable Blazor; switching it to this kept Blazor functioning but fixed ImageSharp.

  • Sven Odén 1 post 71 karma points
    Jul 05, 2023 @ 06:07
    Sven Odén
    0

    Awesome, worked like a charm. Much, much obliged.

  • Chris Smith 39 posts 142 karma points
    Dec 01, 2022 @ 15:36
    Chris Smith
    0

    @Rickard Lövgren

    Thanks for this solution, I've been pulling my hair out for hours over why the cropper was rendering images out at their native size in v10.

    Cheers

    Chris

  • Karl Lee 4 posts 77 karma points
    Dec 16, 2022 @ 13:00
    Karl Lee
    0

    I dont suppose anyone can tell me how to get the image cropper working using a virtual directory?

    I can get the image cropper working using a local image, but images stored on our virtual directory "/media" dont seem to work.

    Thanks

  • Liam Dilley 156 posts 382 karma points
    Oct 18, 2023 @ 01:31
    Liam Dilley
    0

    Hi All, I have found a potential other issue

    If you have an image or images:

    iContent.Value<IEnumerable<MediaWithCrops>>("photoGalleryImages")
    

    Looping and rendering:

    photo.GetCropUrl(cropAlias: "default", furtherOptions: "&format=WebP" );
    

    There are no errors here. BUT the images DO NOT render the crop and only the full size.

    This does not work (renders nothing):

    Url.GetCropUrl(photo, cropAlias: "default", furtherOptions: "&format=WebP")
    

    If you want the format it only seems to work with:

    Url.GetCropUrl(photo, 500, 300, furtherOptions: "&format=WebP")
    
Please Sign in or register to post replies

Write your reply to:

Draft