From ab3aa5aee91a4ea7fe95b697a845c1cc6e795cbd Mon Sep 17 00:00:00 2001 From: Sam Rolfe Date: Mon, 10 Aug 2026 15:07:15 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20remove=20photo=5Furl=20text=20input=20fr?= =?UTF-8?q?om=20user=20form=20(photo=20only=20via=20file=20upload;=20handl?= =?UTF-8?q?er=20keeps=20existing=20photo=20when=20no=20file);=20livewire?= =?UTF-8?q?=20config=20published=20(disk=3Dlocal,=2012MB,=202min=20upload?= =?UTF-8?q?=20=E2=80=94=20was=205s=20default=20breaking=20admin=20temp=20u?= =?UTF-8?q?ploads)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/internal/handlers/tags.go | 10 ++++------ frontend/templates/tag-edit.html | 11 +++++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/frontend/internal/handlers/tags.go b/frontend/internal/handlers/tags.go index c7e7111..3d82010 100644 --- a/frontend/internal/handlers/tags.go +++ b/frontend/internal/handlers/tags.go @@ -110,9 +110,9 @@ func (a *App) EditTag(w http.ResponseWriter, r *http.Request) { return } - // Optional file upload: if a photo file is present, store it and use it; - // otherwise fall back to the photo_url text value. - photoURL := strings.TrimSpace(r.FormValue("photo_url")) + // Photo: only change it when a NEW file is uploaded; otherwise keep the + // tag's current photo (there is no photo_url text field anymore). + photoURL := tag.PhotoUrl.String if err := r.ParseMultipartForm(10 << 20); err == nil { if file, header, ferr := r.FormFile("photo"); ferr == nil { ct := header.Header.Get("Content-Type") @@ -125,10 +125,8 @@ func (a *App) EditTag(w http.ResponseWriter, r *http.Request) { if perr := a.Storage.Put(r.Context(), key, file, header.Size, ct); perr == nil { photoURL = "/photos/" + key } - file.Close() - } else if ferr == nil { - file.Close() } + file.Close() } } diff --git a/frontend/templates/tag-edit.html b/frontend/templates/tag-edit.html index 4427bd5..22f5e62 100644 --- a/frontend/templates/tag-edit.html +++ b/frontend/templates/tag-edit.html @@ -26,10 +26,13 @@
- {{if .Data.PhotoUrl.Valid}}Current photo{{end}} - -

Choose a photo and press Save — or paste an image URL below.

- +
+ {{if .Data.PhotoUrl.Valid}}Current photo{{else}}{{end}} +
+ +

Choose a photo and press Save. If you choose nothing, the current photo is kept.

+
+