-
-
Notifications
You must be signed in to change notification settings - Fork 362
Add avif support #3893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add avif support #3893
Conversation
📝 WalkthroughWalkthroughThis pull request adds AVIF image format support to the FileExtensionService by updating five related constants to recognize AVIF as a supported image format, including file extension mapping, MIME type recognition, and PHP EXIF type compatibility. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Pre-merge checks✅ Passed checks (1 passed)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.php📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🔇 Additional comments (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/Services/Image/FileExtensionService.php (1)
17-84: Add tests for AVIF support.According to the coding guidelines, tests should be written for the new functionality. Please add tests covering:
- AVIF file extension recognition (
isSupportedImageFileExtension)- AVIF MIME type validation (
isSupportedImageMimeType)- AVIF EXIF type support (
hasSupportedExifImageType)- MIME type to extension mapping for AVIF
Run
php artisan testto ensure all tests pass before committing.As per coding guidelines, executable specifications should be written ahead of implementation to drive development.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/Services/Image/FileExtensionService.php
🧰 Additional context used
📓 Path-based instructions (1)
**/*.php
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.php: Any new PHP file should contain the license header and have a single blank line after the opening PHP tag
Variable names should be in snake_case in PHP
Apply the PSR-4 coding standard in PHP
Use in_array() with true as the third parameter in PHP
Only use booleans in if statements, not integers or strings
Use strict comparison (===) instead of loose comparison (==)
Avoid code duplication in both if and else statements
Do not use empty() in PHP
Use the moneyphp/money library for handling monetary values in PHP
Never use floats or doubles to represent monetary values; use integers representing the smallest currency unit (e.g., cents for USD)
**/*.php: Write or extend executable specifications (unit, behaviour, or scenario tests) ahead of implementation, confirm they fail, and then drive code to green before refactoring. List the expected success, validation, and failure branches and add thin failing tests for each path.
For PHP code, adhere to conventions: license headers in new files, strict comparison (===), no empty(), in_array() with third parameter true, snake_case variables, PSR-4 standard, test base classes (AbstractTestCase for Unit, BaseApiWithDataTest for Feature_v2).
Always run phpunit tests. If a test remains red, disable it with a TODO, note the reason, and capture the follow-up in the relevant plan.
Spotless now uses Palantir Java Format 2.78.0 with a 120-character wrap; configure IDE formatters to match before pushing code changes.
Keep each increment's control flow flat by delegating validation/normalisation into tiny pure helpers that return simple enums or result records, then compose them instead of introducing inline branching that inflates the branch count per change.
When introducing new helpers/utilities or editing files prone to style violations (records, DTOs, generated adapters), run the narrowest applicable lint target (for example phpstan) before the full pipeline. Note the command in the related plan/task.
For PHP changes, ru...
Files:
app/Services/Image/FileExtensionService.php
🔇 Additional comments (6)
app/Services/Image/FileExtensionService.php (6)
25-32: LGTM!The
.avifextension is correctly added following the established pattern with lowercase and leading dot.
45-51: LGTM!The
image/avifMIME type is correctly added following the established pattern.
67-84: LGTM!The MIME type to file extension mapping for AVIF is correctly added following the established pattern.
53-65: AI summary inconsistency: AVIF not added to video MIME types.The AI-generated summary claims that
'image/avif'was added toSUPPORTED_VIDEO_MIME_TYPES, but the code shows no such change. This constant only contains video MIME types, which is correct. The summary is inaccurate.
17-23: The changes are compatible with the project's PHP version requirement. The composer.json specifies^8.4(PHP 8.4 or higher), which exceeds the minimum PHP 8.1 whereIMAGETYPE_AVIFwas introduced. No critical issue exists regarding PHP compatibility.Ensure the following coding guidelines are applied before committing:
- Write failing tests first, then drive the code to green
- Run
vendor/bin/php-cs-fixer fixto apply PHP code style fixes- Run
make phpstanto verify PHPStan level 6 compliance- Run
php artisan testto ensure all tests pass
17-23: Verify AVIF support in your deployment environment.PHP GD, ImageMagick, and ExifTool all support AVIF, but require proper compilation:
- PHP GD: Requires libavif (≥0.8.2) and
--with-avifbuild flag- ImageMagick: Requires AVIF/HEIF delegates (libheif ≥1.7.0, recommend ≥1.15 for stability)
- ExifTool: Supports AVIF metadata read/write
Ensure your deployment environment has these dependencies compiled in before using AVIF in production.
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
Fixes #1790
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.