Skip to content

[2.x] feat: convert uploaded avatars to WebP, add batch migration command#4431

Merged
imorland merged 3 commits into2.xfrom
im/avatar-webp
Mar 12, 2026
Merged

[2.x] feat: convert uploaded avatars to WebP, add batch migration command#4431
imorland merged 3 commits into2.xfrom
im/avatar-webp

Conversation

@imorland
Copy link
Copy Markdown
Member

Summary

  • WebP output: AvatarUploader now encodes all static image uploads as .webp instead of .png. Animated GIFs are preserved as-is.
  • WebP input: AvatarValidator adds webp to the list of accepted MIME types so users can upload WebP files directly.
  • File picker: AvatarEditor now uses MIME types in the <input accept> attribute (image/jpeg,image/png,image/gif,image/webp,image/bmp) for better OS-level filtering, replacing the previous extension-based list.
  • Migration command: New php flarum avatars:convert-to-webp CLI command to batch-convert existing local avatars (PNG/JPEG/BMP) to WebP. Uses chunkById(100) for memory efficiency, isolates per-user errors, and reports converted/missing/failed counts.
  • Test: Added test_upload_stores_webp_for_static_images() to assert new uploads produce a .webp path.

Test plan

  • Upload a JPEG, PNG, BMP, GIF, and WebP — verify only animated GIFs remain .gif, all others saved as .webp
  • Run php flarum avatars:convert-to-webp against a forum with existing PNG avatars — verify files are converted and DB updated
  • Run unit tests: phpunit framework/core/tests/unit/User/AvatarUploaderTest.php
  • Verify file picker on avatar upload filters to the correct image types on macOS/Windows/mobile

🤖 Generated with Claude Code

imorland and others added 2 commits March 12, 2026 02:04
- AvatarUploader: encode static images as WebP instead of PNG; animated GIFs unchanged
- AvatarValidator: accept WebP as a valid upload format
- AvatarEditor: use MIME types in file picker accept attribute (includes image/webp)
- Add `avatars:convert-to-webp` CLI command to batch-convert existing local avatars
- Add unit test asserting new uploads produce a .webp path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imorland imorland requested a review from a team as a code owner March 12, 2026 01:05
@imorland imorland changed the title feat(avatars): convert uploads to WebP, add batch migration command [2.x] feat(): convert uploaded avatars to WebP, add batch migration command Mar 12, 2026
@imorland imorland changed the title [2.x] feat(): convert uploaded avatars to WebP, add batch migration command [2.x] feat: convert uploaded avatars to WebP, add batch migration command Mar 12, 2026
@imorland imorland modified the milestone: 2.0.0-beta.8 Mar 12, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imorland imorland merged commit 846e629 into 2.x Mar 12, 2026
27 checks passed
@imorland imorland deleted the im/avatar-webp branch March 12, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants