Repository navigation
Only attempt to get dominant colour for image mime types. - #2264
westonruter merged 6 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #2264 +/- ##
==========================================
+ Coverage 69.17% 69.21% +0.04%
==========================================
Files 90 90
Lines 7696 7703 +7
==========================================
+ Hits 5324 5332 +8
+ Misses 2372 2371 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Weston Ruter <westonruter@gmail.com>
|
@peterwilsoncc Is this still a draft on purpose? |
There was a problem hiding this comment.
Pull request overview
This PR restricts dominant color detection to supported image MIME types only, preventing the feature from attempting to process non-image attachments like videos or ZIP files. The change replaces a PDF-specific check with an allowlist approach.
Changes:
- Replaced the blocklist approach (checking for
application/pdf) with an allowlist of supported image MIME types - Added a filter hook to allow third-party developers to extend supported MIME types
- Updated error handling to return a more generic
unsupported_attachment_typeerror
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1d7d048 to
c07f4dd
Compare
From memory I wanted to add a test but forgot to do so after 6.9 dropped. I've added it in 0e70a0c |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Summary
Modifies the dominant colour detection function to use an allow list of mime types based on image types supported in WordPress. This prevents the feature from running on other media types such as video, zips, etc.
Fixes #1957
Relevant technical choices
Runs the colour detection on the supported mime types
Introduces the filter
dominant_color_supported_mime_typesto allow third party developers to extend the feature.Use of AI Tools
N/A