Search code examples
c#razorblazormauimudblazor

.NET MAUI Blazor Hybrid local images not loading


Working on a .NET MAUI Blazor Hybrid and using MudBlazor for my UI. Images are currently not loading in my app. I have the following declared in the project file:

<!-- Images -->
<MauiImage Include="Resources\Images\*" />

Example call in the razor UI:

<MudAvatar Image="resources/images/foo.jpeg" Size="Size.Large" />

I should also mention if I call an external image in the razor UI it works. Following example image loads without any issues:

<MudAvatar Image="https://pbs.twimg.com/profile_images/1313493454710857730/ddYgxm9j_400x400.jpg" Size="Size.Large" />

I am testing the app in the Android Emulator and confirmed the image properties Build Action is set to MauiImage.

Am I missing something? Thanks in advance!


Solution

  • You can try to create a new folder named images below the project's wwwroot folder. Such as:

    enter image description here

    And then you can display the image such as:

    <MudAvatar Image="images/foo.jpeg" Size="Size.Large" />