Implement automatic generation of multiple image sizes for responsive delivery and enhanced feed optimization. Changes: - Add migration 009 for media_variants table with CASCADE delete - Define variant specs: thumb (150x150 crop), small (320px), medium (640px), large (1280px) - Implement generate_variant() with center crop for thumbnails and aspect-preserving resize - Implement generate_all_variants() with try/except cleanup, pass year/month/optimized_bytes explicitly - Update save_media() to generate all variants after saving original - Update get_note_media() to include variants dict (backwards compatible - only when variants exist) - Record original as 'original' variant type Technical details: - Variants use explicit year/month parameters to avoid fragile path traversal - Pass optimized_bytes to avoid redundant file I/O - File cleanup on variant generation failure - Skip generating variants larger than source image - variants key only added to response when variants exist (pre-v1.4.0 compatibility) All existing tests pass. Phase 2 complete. Per design document: /home/phil/Projects/starpunk/docs/design/v1.4.0/media-implementation-design.md Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
19 KiB
19 KiB