From c3d196df03944d3df2c5a0c8d9d9c816a7f64cb2 Mon Sep 17 00:00:00 2001 From: DavidHerran Date: Wed, 6 May 2026 15:21:08 -0500 Subject: [PATCH] feat: auto-optimize images on CMS upload via AssetBucketBrowser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enables the existing Sharp pipeline for all uploads — WebP conversion, auto-orient, 2560px cap, content-hash filenames. Upload toast now shows compression savings percentage. Co-Authored-By: Claude Opus 4.6 --- src/components/hq/AssetBucketBrowser.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/hq/AssetBucketBrowser.tsx b/src/components/hq/AssetBucketBrowser.tsx index 9c9d70a..d794fb9 100644 --- a/src/components/hq/AssetBucketBrowser.tsx +++ b/src/components/hq/AssetBucketBrowser.tsx @@ -193,10 +193,17 @@ export default function AssetBucketBrowser({ fd.append("slug", slug); fd.append("path", activeBucket.path); fd.append("file", file); + fd.append("optimize", "1"); const res = await fetch("/api/assets", { method: "POST", body: fd }); const data = await res.json(); if (data.success) { - setUploadProgress(`✓ ${data.file.name}`); + const f = data.file; + if (f.optimized && f.savedBytes > 0) { + const pct = Math.round((f.savedBytes / f.originalBytes) * 100); + setUploadProgress(`✓ ${f.name} (−${pct}% optimized)`); + } else { + setUploadProgress(`✓ ${f.name}`); + } await fetchItems(); setTimeout(() => setUploadProgress(""), 1500); } else {