diff --git a/blazor_lab/Pages/List.razor b/blazor_lab/Pages/List.razor index 1437cd6..1dcbc5d 100644 --- a/blazor_lab/Pages/List.razor +++ b/blazor_lab/Pages/List.razor @@ -20,6 +20,18 @@ Responsive> + + + @if (File.Exists($"{WebHostEnvironment.WebRootPath}/images/{context.Name}.png")) + { + @context.DisplayName + } + else + { + @context.DisplayName + } + + diff --git a/blazor_lab/Pages/List.razor.cs b/blazor_lab/Pages/List.razor.cs index a37dac3..818b8af 100644 --- a/blazor_lab/Pages/List.razor.cs +++ b/blazor_lab/Pages/List.razor.cs @@ -20,6 +20,9 @@ namespace blazor_lab.Pages [Inject] public NavigationManager NavigationManager { get; set; } + [Inject] + public IWebHostEnvironment WebHostEnvironment { get; set; } + protected override async Task OnAfterRenderAsync(bool firstRender) { // Do not treat this action if is not the first render diff --git a/blazor_lab/blazor_lab.csproj b/blazor_lab/blazor_lab.csproj index 011212e..bf3e670 100644 --- a/blazor_lab/blazor_lab.csproj +++ b/blazor_lab/blazor_lab.csproj @@ -13,4 +13,8 @@ + + + + diff --git a/blazor_lab/wwwroot/images/default.png b/blazor_lab/wwwroot/images/default.png new file mode 100644 index 0000000..a7446c9 Binary files /dev/null and b/blazor_lab/wwwroot/images/default.png differ diff --git a/blazor_lab/wwwroot/images/with img this time.png b/blazor_lab/wwwroot/images/with img this time.png new file mode 100644 index 0000000..989ea6a Binary files /dev/null and b/blazor_lab/wwwroot/images/with img this time.png differ