From e5f0202a4a1a069172d47e286877bf86fd6430e3 Mon Sep 17 00:00:00 2001 From: Padreug Date: Thu, 21 May 2026 00:26:12 +0200 Subject: [PATCH] feat(base): default ImageUpload compression on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flip ImageUploadOptions.compress so undefined/true → compress with default knobs, false → skip, object → compress with merged knobs. A future consumer that forgets the prop now gets safe behavior (small WebP) instead of dumping a 5–8 MB phone photo to pict-rs. Drop the now-redundant :compress="true" from the events banner and market product call sites. Profile keeps its object override since it tunes maxWidthOrHeight: 512 / maxSizeMB: 0.2 for avatars. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/modules/activities/components/CreateEventDialog.vue | 1 - src/modules/base/components/ImageUpload.vue | 7 ++++--- src/modules/base/services/ImageUploadService.ts | 8 ++++++-- src/modules/market/components/CreateProductDialog.vue | 1 - 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/modules/activities/components/CreateEventDialog.vue b/src/modules/activities/components/CreateEventDialog.vue index 1855049..dd5ab5f 100644 --- a/src/modules/activities/components/CreateEventDialog.vue +++ b/src/modules/activities/components/CreateEventDialog.vue @@ -396,7 +396,6 @@ const handleOpenChange = (open: boolean) => { :show-primary-button="false" :disabled="isLoading" :allow-camera="true" - :compress="true" placeholder="Add a poster or banner" /> diff --git a/src/modules/base/components/ImageUpload.vue b/src/modules/base/components/ImageUpload.vue index 71f96af..228e7ec 100644 --- a/src/modules/base/components/ImageUpload.vue +++ b/src/modules/base/components/ImageUpload.vue @@ -176,9 +176,10 @@ const props = defineProps<{ placeholder?: string allowCamera?: boolean /** - * Client-side resize + re-encode before upload. Pass `true` for the - * service defaults (1920px max edge, WebP, ~1MB target), or an object - * to tune individual knobs. + * Client-side resize + re-encode before upload. Default-on with the + * service defaults (1920px max edge, WebP, ~1MB target). Pass an + * object to tune individual knobs, or `false` to upload the original + * untouched. */ compress?: boolean | CompressOptions }>() diff --git a/src/modules/base/services/ImageUploadService.ts b/src/modules/base/services/ImageUploadService.ts index d045a11..2063ce3 100644 --- a/src/modules/base/services/ImageUploadService.ts +++ b/src/modules/base/services/ImageUploadService.ts @@ -34,7 +34,9 @@ export interface ImageUploadOptions { maxSizeMB?: number acceptedTypes?: string[] generateThumbnail?: boolean - /** Enable client-side resize + re-encode before upload. */ + /** Client-side resize + re-encode before upload. Default `true` with + * default knobs (1920 px, WebP, ~1 MB). Pass an object to tune knobs + * or `false` to upload the original untouched. */ compress?: boolean | CompressOptions } @@ -333,7 +335,9 @@ export class ImageUploadService extends BaseService { * JPEG if the browser can't encode WebP. */ private async maybeCompress(file: File, options: ImageUploadOptions): Promise { - if (!options.compress) return file + // Default-on: undefined / true → compress with default knobs; + // object → compress with merged knobs; false → skip entirely. + if (options.compress === false) return file const opts: Required = { ...DEFAULT_COMPRESS, diff --git a/src/modules/market/components/CreateProductDialog.vue b/src/modules/market/components/CreateProductDialog.vue index 17d536d..dd5b505 100644 --- a/src/modules/market/components/CreateProductDialog.vue +++ b/src/modules/market/components/CreateProductDialog.vue @@ -136,7 +136,6 @@ :show-primary-button="true" :disabled="isCreating" :allow-camera="true" - :compress="true" placeholder="Add product photos" />