From 616aa3a934951260d5daa81ab3d0f93fbc94ebee Mon Sep 17 00:00:00 2001 From: grm Date: Thu, 17 Sep 2026 18:54:33 +0300 Subject: Keep a chosen image older than the picker's list, and the layout on a rejected save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The image picker's select lists the newest recentImages library images and was meant to add the chosen one when it is older than those, but the fallback option was gated on the filename being unknown, which designData makes known: the option never rendered, the browser selected "None", and every save of the design form cleared a logo or favicon older than the 48 newest images (the post form's featured image the same way). The partial now checks whether the choice is listed and otherwise emits it, named. handleDesign ran the uploads before parsing the module and menu rows and gave up at the first problem, so a rejected upload rendered the form without any rows — and, since a missing row means delete, the next save would have wiped the layout and menu. Everything is read before the first problem is reported. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/templates/partials/imagepick.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'internal/web/templates/partials') diff --git a/internal/web/templates/partials/imagepick.html b/internal/web/templates/partials/imagepick.html index ed9368c..5062d42 100644 --- a/internal/web/templates/partials/imagepick.html +++ b/internal/web/templates/partials/imagepick.html @@ -1,9 +1,11 @@ {{/* One image field of a form (the design page, a post's featured image). - The select lists the recent images (plus the chosen one) so it works - without the script; with it the select is hidden and "Choose from - library…" opens the form's imagelib panel, which fetches the library - page by page and marks the pickers with .js. */}} -{{define "imagepick"}}{{$cur := .current}}
+ The select lists the recent images so it works without the script; a + chosen image older than those gets its own option (named through .names, + or "Current image" once the file is gone), so the select always carries + the choice and a save keeps it. With the script the select is hidden and + "Choose from library…" opens the form's imagelib panel, which fetches the + library page by page and marks the pickers with .js. */}} +{{define "imagepick"}}{{$cur := .current}}{{$listed := false}}{{range .images}}{{if eq .ID.String $cur}}{{$listed = true}}{{end}}{{end}}
{{if .hint}}

{{.hint}}

{{end}}
@@ -12,7 +14,7 @@ -- cgit v1.2.3