feat: serve width-bounded thumbnail variants for image grids

Add /files/{key}?w=<px>: the endpoint decodes JPEG/PNG sources, downscales to
a width snapped to a small allow-list (aspect-preserving, never upscaling),
caches the result under a thumbs/ prefix, and serves it — so cover grids
download ~KB instead of the 1–5 MB original. Cover handlers purge cached
variants when a cover (whose key is reused) is replaced or deleted. Frontend
grids use new thumbUrl/thumbSrcset helpers (MangaCard with responsive srcset).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-11 14:41:19 +02:00
parent 5b1ce581f3
commit 755417730f
13 changed files with 380 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import { fileUrl } from '$lib/api/client';
import { thumbUrl } from '$lib/api/client';
import type { Bookmark } from '$lib/api/bookmarks';
import { overflowTooltip } from '$lib/actions/overflowTooltip';
import BookImage from '@lucide/svelte/icons/book-image';
@@ -19,7 +19,7 @@
<a href="/manga/{b.manga_id}" class="cover-link" aria-hidden="true" tabindex="-1">
{#if b.manga_cover_image_path}
<img
src={fileUrl(b.manga_cover_image_path)}
src={thumbUrl(b.manga_cover_image_path, 320)}
alt=""
class="cover"
loading="lazy"