Changeset 8f6225c in Klonkt for src/routes/posts.js


Ignore:
Timestamp:
06/20/2026 01:57:35 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
85d5972
Parents:
fa08981
Message:

feat(images): new uploads automatically converted to WebP

Shared ImageWebpService.toWebp() converts uploaded images via cwebp (q82)
and removes the original; cwebp absent/error → original preserved (graceful).
Wired up in all upload routes: post images/cover, avatar, site photo, hub
hero, audio cover. GIF stays GIF, already-webp skipped.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    rfa08981 r8f6225c  
    1616import PlaylistService from '../services/PlaylistService.js';
    1717import { audioUrl } from '../services/AudioStreamService.js';
     18import { toWebp } from '../services/ImageWebpService.js';
    1819
    1920const __dirname = path.dirname(fileURLToPath(import.meta.url));
     
    5556    if (err) return res.status(400).json({ error: err.message });
    5657    if (!req.file) return res.status(400).json({ error: 'No file' });
    57     const url = '/media/post-images/' + req.file.filename;
     58    const url = '/media/post-images/' + toWebp(req.file);
    5859    res.json({ url, size: req.file.size, mime: req.file.mimetype });
    5960  });
Note: See TracChangeset for help on using the changeset viewer.