Poet images: placeholder instead of broken images (#4)

- poet ImageUrl always points at the API image endpoint
- endpoint serves a neutral SVG placeholder when a poet has no portrait
- public data export: poet image URLs use our API (WebServiceUrl), not ganjoor.net

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Anas Rashid 2026-10-05 00:06:28 +02:00
parent 90f07bf10e
commit 8bb26a0296
3 changed files with 15 additions and 5 deletions

View File

@ -315,6 +315,12 @@ namespace RMuseum.Controllers
return Ok();
}
private const string PoetImagePlaceholderSvg =
"<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'>" +
"<rect width='200' height='200' fill='#efe7d6'/>" +
"<circle cx='100' cy='78' r='34' fill='#c9b896'/>" +
"<path d='M40 176c6-38 32-58 60-58s54 20 60 58z' fill='#c9b896'/></svg>";
/// <summary>
/// get poet image with png ext
/// </summary>
@ -355,7 +361,11 @@ namespace RMuseum.Controllers
return BadRequest(poet.ExceptionString);
if (poet.Result == Guid.Empty)
return NotFound();
{
// divan: portraits are optional (deferred); serve a neutral placeholder instead of a broken image
Response.Headers.CacheControl = "public,max-age=86400";
return Content(PoetImagePlaceholderSvg, "image/svg+xml");
}
RServiceResult<RImage> img =

View File

@ -253,7 +253,7 @@ namespace RMuseum.Services.Implementation
Nickname = poet.Nickname,
Description = poet.Description,
FullUrl = catPoet.FullUrl,
ImageUrl = poet.RImageId == null ? null : $"https://ganjoor.net/api/divan/poet/image{catPoet.FullUrl}.gif",
ImageUrl = poet.RImageId == null ? null : $"{WebServiceUrl.Url}/api/divan/poet/image{catPoet.FullUrl}.gif", // divan: own API, not ganjoor.net
BirthYearInLHijri = poet.BirthYearInLHijri,
ValidBirthDate = poet.ValidBirthDate,
DeathYearInLHijri = poet.DeathYearInLHijri,

View File

@ -62,7 +62,7 @@ namespace RMuseum.Services.Implementation
RootCatId = cat.Id,
Nickname = poet.Nickname,
Published = poet.Published,
ImageUrl = poet.RImageId == null ? "" : $"/api/divan/poet/image{cat.FullUrl}.gif",
ImageUrl = $"/api/divan/poet/image{cat.FullUrl}.gif",
BirthYearInLHijri = poet.BirthYearInLHijri,
DeathYearInLHijri = poet.DeathYearInLHijri,
ValidBirthDate = poet.ValidBirthDate,
@ -453,7 +453,7 @@ namespace RMuseum.Services.Implementation
RootCatId = context.DivanCategories.Where(c => c.PoetId == poet.Id && c.ParentId == null).Single().Id,
Nickname = poet.Nickname,
Published = poet.Published,
ImageUrl = poet.RImageId == null ? "" : $"/api/divan/poet/image{context.DivanCategories.Where(c => c.PoetId == poet.Id && c.ParentId == null).Single().FullUrl}.gif",
ImageUrl = $"/api/divan/poet/image{context.DivanCategories.Where(c => c.PoetId == poet.Id && c.ParentId == null).Single().FullUrl}.gif",
BirthYearInLHijri = poet.BirthYearInLHijri,
DeathYearInLHijri = poet.DeathYearInLHijri,
ValidBirthDate = poet.ValidBirthDate,
@ -623,7 +623,7 @@ namespace RMuseum.Services.Implementation
RootCatId = cat.Id,
Nickname = poet.Nickname,
Published = poet.Published,
ImageUrl = poet.RImageId == null ? "" : $"/api/divan/poet/image{cat.FullUrl}.gif",
ImageUrl = $"/api/divan/poet/image{cat.FullUrl}.gif",
BirthYearInLHijri = poet.BirthYearInLHijri,
ValidBirthDate = poet.ValidBirthDate,
ValidDeathDate = poet.ValidDeathDate,