feat(photos): add square medium variant for sharp grid thumbnails

This commit is contained in:
iu
2026-10-11 19:57:00 +03:00
parent 581e479f03
commit f1b3b01bdf
27 changed files with 459 additions and 32 deletions
+18 -4
View File
@@ -61,13 +61,27 @@ func (s *Service) List(ctx context.Context, userID string) ([]models.Album, erro
return out, nil
}
// attachCover fills CoverThumbURL from the signed thumbnail URL, when present.
// attachCover fills CoverThumbURL and CoverMediumURL from signed URLs. The
// medium URL falls back to the thumbnail while the medium variant is not ready,
// so a cover URL suitable for large display is always present when a cover is
// set.
func (s *Service) attachCover(ctx context.Context, a *models.Album) {
if s.storage == nil || a == nil || a.CoverThumbKey == "" {
if s.storage == nil || a == nil {
return
}
if url, err := s.storage.URL(ctx, a.CoverThumbKey); err == nil {
a.CoverThumbURL = url
if a.CoverThumbKey != "" {
if url, err := s.storage.URL(ctx, a.CoverThumbKey); err == nil {
a.CoverThumbURL = url
}
}
key := a.CoverMediumKey
if key == "" {
key = a.CoverThumbKey
}
if key != "" {
if url, err := s.storage.URL(ctx, key); err == nil {
a.CoverMediumURL = url
}
}
}