Copied to clipboard

Flag this post as spam?

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


  • Kamil 6 posts 75 karma points
    Jun 17, 2022 @ 06:32
    Kamil
    0

    Hi,

    yesterday I began the process of migrating my Umbraco 8 build over to Umbraco 10. So far it's been pretty flawless (got the build up and running within few hours) - altough I'm struggling to get the WebP optimization to work properly.

    I've registered the ImageSharp2 in the startup as follows:

        public void ConfigureServices(IServiceCollection services)
        {
           ...
    
            services.AddUmbraco(_env, _config)
                .AddBackOffice()
                .AddWebsite()
                .AddComposers()
                .Build();
    
            services.AddImageSharp();
        }
    

    and

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        ...
        app.UseUmbraco()
            .WithMiddleware(u =>
            {
                u.UseBackOffice();
                u.UseWebsite();
            })
            .WithEndpoints(u =>
            {
                u.UseInstallerEndpoints();
                u.UseBackOfficeEndpoints();
                u.UseWebsiteEndpoints();
            });
    
         app.UseImageSharp();
    }
    

    The result I get is that static files are optimized properly, but media library items aren't. I tried putting these methods in different orders but the result is the same.

    Maybe anyone knows / sees what is the problem here?

    Best, Kamil

  • Søren Kottal 641 posts 4110 karma points MVP 4x c-trib
    Jun 17, 2022 @ 06:47
    Søren Kottal
    0

    Umbraco should register ImageSharp for you, try removing your own registration and see if that works.

  • Kamil 6 posts 75 karma points
    Jun 17, 2022 @ 07:36
    Kamil
    0

    Thanks for your answer - it doesn't have any effect. I think I found the cause - altough not a fix yet.

    My case is that my Media files from Umbraco 8 are stored in folder ~/Media (from the root of the solution).

    Newly uploaded files land in ~/wwwroot/media with correct path stored in the DB.

    First issue here is that they aren't served properly returning 404.

    Second issue here is that the ImageSharp by default expects the source to be coming from wwwroot, therefore it does not work for my existing images. Ref: https://github.com/SixLabors/ImageSharp.Web/issues/135

  • Kamil 6 posts 75 karma points
    Jun 17, 2022 @ 07:56
    Kamil
    100

    OK - I've found the solution. Because I've left the Media folder untouched, the same issue happened for me as described here: https://our.umbraco.com/forum/using-umbraco-and-getting-started/107870-umbraco-9-upload-problem-media-uploads-to-wwwrootmedia-but-gets-loaded-from-media

    I've copied the elements over in the wwwroot/media and removed the original Media folder and both issues are solved.

    About my original question: The ImageSharp does not work without explicitly registering it but that's not a problem.

    Now, as the media files are served from wwwroot, it works.

Please Sign in or register to post replies

Write your reply to:

Draft