All product images uploaded through the admin dashboard are automatically converted to WebP format before being stored in Supabase Storage. This client-side conversion reduces file sizes and ensures consistent image delivery across the storefront. News article cover images follow a similar upload flow but retain their original format.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/bicyblex/bicyblexStore/llms.txt
Use this file to discover all available pages before exploring further.
convertToWebP(file, quality) utility
The convertToWebP function in src/utils/imageUtils.js handles the entire conversion process in the browser using the Canvas API. It accepts any image format the browser supports and returns a Promise<File> that resolves to a .webp file.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
file | File | — | The original image file selected by the user |
quality | number | 0.8 | WebP compression quality (0–1, where 1 is lossless) |
Promise<File> — a new File object with the .webp extension.
src/utils/imageUtils.js
FileReaderreads the original file as a data URL- An
Imageelement loads the data URL to get the original dimensions - A
<canvas>is created at the same dimensions and the image is drawn onto it canvas.toBlob()exports the canvas as a WebP blob at the specified quality- The blob is wrapped in a new
Filewith the.webpextension
Product image upload flow
When an admin submits a new or updated product with an image,ProductManager.jsx runs the following sequence:
User selects an image file
The product form accepts any image type via
<input type="file" accept="image/*">. The selected file is stored in formData.imageFile.Upload to Supabase Storage
The converted file is uploaded to the
products bucket with a unique timestamped filename:News image upload flow
News article cover images follow a similar upload pattern, but they are not converted to WebP — the original file extension is preserved. Images are stored under thenews/ path prefix inside the news bucket.
image URL is preserved.
Storage buckets summary
| Bucket | Used for | Path pattern | Image format |
|---|---|---|---|
products | Product images | {timestamp}_{random}.webp | WebP (converted client-side) |
news | News article cover images | news/{timestamp}-{random}.{ext} | Original format |
Both buckets must be set to public in the Supabase dashboard for the image URLs to be accessible on the storefront. See Supabase Setup for instructions on creating and configuring the buckets.
