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 79 karma points
    Jun 17, 2022 @ 06:32
    Kamil
    0

    Umbraco 10 and WebP

    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 713 posts 4571 karma points MVP 6x 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 79 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 79 karma points
    Jun 17, 2022 @ 07:56
    Kamil
    102

    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.

  • Heather Floyd 610 posts 1032 karma points MVP 6x c-trib
    Jan 13, 2023 @ 18:31
    Heather Floyd
    0

    FYI - This is a good explanation of enabling full webP support for Umbraco 10: https://us.umbhost.net/blog/2022/06/dynamic-webp-images-in-umbraco-v10

  • Yakov Lebski 591 posts 2347 karma points
    Jan 14, 2023 @ 00:34
    Yakov Lebski
    0

    You can use this package https://marketplace.umbraco.com/package/dyfort.umbraco.autoimageoptimize it will do it automatically

  • Ceglius 1 post 21 karma points
    May 10, 2023 @ 17:31
    Ceglius
    0

    Hi Yakov, does your package works with umbraco 11?

  • Yakov Lebski 591 posts 2347 karma points
    May 10, 2023 @ 22:58
    Yakov Lebski
    0

    Yes, it works for Umbraco 11 as well.

  • curtismccaw 28 posts 88 karma points
    Dec 11, 2023 @ 11:29
    curtismccaw
    0

    Hi Yakov, i've installed the package on my local site but not seeing any conversion. Do I need to set anything else up?

  • Danine Noble 82 posts 368 karma points
    Dec 13, 2023 @ 18:46
    Danine Noble
    0

    Did you clear the umbraco\Data\TEMP\MediaCache folder?

Please Sign in or register to post replies

Write your reply to:

Draft