fix: remove photo_url text input from user form (photo only via file upload; handler keeps existing photo when no file); livewire config published (disk=local, 12MB, 2min upload — was 5s default breaking admin temp uploads)

This commit is contained in:
2026-08-10 15:07:15 +10:00
parent f5e5989c64
commit ab3aa5aee9
2 changed files with 11 additions and 10 deletions

View File

@@ -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()
}
}

View File

@@ -26,10 +26,13 @@
</div>
<div>
<label class="block text-sm font-medium">Photo</label>
{{if .Data.PhotoUrl.Valid}}<img src="{{.Data.PhotoUrl.String}}" alt="Current photo" class="mb-2 h-24 w-24 rounded-lg object-cover">{{end}}
<input type="file" name="photo" accept="image/*" class="mt-1 text-sm">
<p class="mt-1 text-xs text-stone-500">Choose a photo and press Save — or paste an image URL below.</p>
<input name="photo_url" type="text" value="{{if .Data.PhotoUrl.Valid}}{{.Data.PhotoUrl.String}}{{end}}" class="mt-1 w-full rounded border border-stone-300 px-3 py-2" placeholder="https://…">
<div class="flex items-center gap-3">
{{if .Data.PhotoUrl.Valid}}<img src="{{.Data.PhotoUrl.String}}" alt="Current photo" class="h-24 w-24 rounded-lg object-cover">{{else}}<img id="photo-preview" class="hidden h-24 w-24 rounded-lg object-cover" alt="New photo">{{end}}
<div>
<input type="file" name="photo" accept="image/*" class="text-sm" onchange="var f=this.files[0]; if(f){ var r=new FileReader(); r.onload=function(e){ var p=document.getElementById('photo-preview'); p.src=e.target.result; p.classList.remove('hidden'); }; r.readAsDataURL(f); }">
<p class="mt-1 text-xs text-stone-500">Choose a photo and press Save. If you choose nothing, the current photo is kept.</p>
</div>
</div>
</div>
<div>
<label class="block text-sm font-medium">Phone number (shown to finders)</label>