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 @@
Choose a photo and press Save — or paste an image URL below.
- +Choose a photo and press Save. If you choose nothing, the current photo is kept.
+