using Microsoft.AspNetCore.Mvc.RazorPages; namespace StatiKosev.Pages; public class Gallery(IWebHostEnvironment env) : PageModel { static readonly string[] ImageExtensions = [".png", ".jpg", ".jpeg", ".webp", ".gif"]; public IReadOnlyList Images { get; private set; } = []; //every image in wwwroot/images except the profile photo used on the home page public void OnGet() { var dir = Path.Combine(env.WebRootPath, "images"); if (!Directory.Exists(dir)) return; Images = Directory.EnumerateFiles(dir) .Where(f => ImageExtensions.Contains(Path.GetExtension(f).ToLowerInvariant())) .Select(Path.GetFileName) .Where(n => !n!.StartsWith("profile.", StringComparison.OrdinalIgnoreCase)) .Order() .Select(n => "/images/" + n) .ToList(); } }