Changeset 28bf7f0 in Klonkt
- Timestamp:
- 06/30/2026 03:26:08 PM (2 months ago)
- Branches:
- main
- Children:
- 28f797d
- Parents:
- 4d1aefb
- File:
-
- 1 edited
-
src/views/pages/post-edit.ejs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/views/pages/post-edit.ejs
r4d1aefb r28bf7f0 1206 1206 } 1207 1207 1208 // True for an animated WebP (VP8X chunk with the animation flag set) — like a GIF it must skip 1209 // the canvas editor, otherwise it'd be flattened to a single static frame. 1210 async function isAnimatedWebpFile(file) { 1211 if (!file || file.type !== 'image/webp') return false; 1212 try { 1213 const b = new Uint8Array(await file.slice(0, 40).arrayBuffer()); 1214 return b.length >= 21 && String.fromCharCode(b[12], b[13], b[14], b[15]) === 'VP8X' && (b[20] & 0x02) !== 0; 1215 } catch (_) { return false; } 1216 } 1217 1208 1218 // Opens the editor for a chosen file; resolves with an edited File, 1209 // or null if the user cancels. Animated GIFs are notsent through the1219 // or null if the user cancels. Animated images (GIF / animated WebP) are NOT sent through the 1210 1220 // canvas editor (they would become static) — those upload directly. 1211 1221 async function openImageEditor(file) { 1212 1222 if (!file || !file.type || !file.type.startsWith('image/')) return file; 1213 if (file.type === 'image/gif') return file; // preserve animation 1223 if (file.type === 'image/gif') return file; // preserve animation 1224 if (await isAnimatedWebpFile(file)) return file; // animated WebP → preserve animation 1214 1225 try { await ensureCropper(); } catch (_) { return file; } // editor unavailable → upload directly 1215 1226
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)