From e33ac9af0acb3153bb68d4453722d256b1cf5cf8 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 3 Oct 2022 07:03:38 +0100 Subject: [PATCH] add /storage/thumb/media/:slug defroute (re-added). I think I had a version of this route but I deleted it -- can't remember if it wasn't needed or didn't work as intended at the time. Anyway, this commit makes it part of the code-base (again). The function provides the website to use the automatically generated thumbnails -- when a user uploads the an image to /storage/media -- instead of the full-sized image. This should help reduce download times if a list of uploaded image are several Mega Bytes and being viewed at once -- like an index page for example. --- src/web.lisp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/web.lisp b/src/web.lisp index 0b4cd39..f228328 100644 --- a/src/web.lisp +++ b/src/web.lisp @@ -759,6 +759,15 @@ (nera:get-storage-file :slug slug)))) (on-exception *web* 404))) +(defroute ("/storage/thumb/media/:slug" :method :GET) (&key slug) + (let ((storage-file (nera:get-storage-file :slug slug))) + (if storage-file + `(200 (:content-type ,(files::file-type-of storage-file)) + ,(storage:open-binary-file + "" "media" + (format nil "thumbnail-~a" (files::name-of storage-file)))) + (on-exception *web* 404)))) + (defroute ("/storage/thumb/archive/:slug" :method :GET) (&key slug) (if (nera:get-archive-entry :slug slug) (let ((archive-entry (nera:get-archive-entry :slug slug)))