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:
@@ -110,9 +110,9 @@ func (a *App) EditTag(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optional file upload: if a photo file is present, store it and use it;
|
// Photo: only change it when a NEW file is uploaded; otherwise keep the
|
||||||
// otherwise fall back to the photo_url text value.
|
// tag's current photo (there is no photo_url text field anymore).
|
||||||
photoURL := strings.TrimSpace(r.FormValue("photo_url"))
|
photoURL := tag.PhotoUrl.String
|
||||||
if err := r.ParseMultipartForm(10 << 20); err == nil {
|
if err := r.ParseMultipartForm(10 << 20); err == nil {
|
||||||
if file, header, ferr := r.FormFile("photo"); ferr == nil {
|
if file, header, ferr := r.FormFile("photo"); ferr == nil {
|
||||||
ct := header.Header.Get("Content-Type")
|
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 {
|
if perr := a.Storage.Put(r.Context(), key, file, header.Size, ct); perr == nil {
|
||||||
photoURL = "/photos/" + key
|
photoURL = "/photos/" + key
|
||||||
}
|
}
|
||||||
file.Close()
|
|
||||||
} else if ferr == nil {
|
|
||||||
file.Close()
|
|
||||||
}
|
}
|
||||||
|
file.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">Photo</label>
|
<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}}
|
<div class="flex items-center gap-3">
|
||||||
<input type="file" name="photo" accept="image/*" class="mt-1 text-sm">
|
{{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}}
|
||||||
<p class="mt-1 text-xs text-stone-500">Choose a photo and press Save — or paste an image URL below.</p>
|
<div>
|
||||||
<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://…">
|
<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>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">Phone number (shown to finders)</label>
|
<label class="block text-sm font-medium">Phone number (shown to finders)</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user