-
Notifications
You must be signed in to change notification settings - Fork 138
Only attempt to get dominant colour for image mime types. #2264
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
base: trunk
Are you sure you want to change the base?
Only attempt to get dominant colour for image mime types. #2264
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #2264 +/- ##
==========================================
+ Coverage 68.86% 68.89% +0.02%
==========================================
Files 90 90
Lines 7610 7617 +7
==========================================
+ Hits 5241 5248 +7
Misses 2369 2369
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:
|
| * Filter the array of supported mime types for dominant color extraction, by default the plugin | ||
| * supports image types supported by WordPress Core. | ||
| * | ||
| * @since x.x.x |
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.
These n.e.x.t versions automatically get replaced prior to a release.
| * @since x.x.x | |
| * @since n.e.x.t |
| * | ||
| * @param string[] $supported_mime_types Array of supported mime types. Defaults are 'image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/avif'. | ||
| */ | ||
| $supported_mime_types = apply_filters( 'dominant_color_supported_mime_types', $supported_mime_types ); |
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.
For type safety.
| $supported_mime_types = apply_filters( 'dominant_color_supported_mime_types', $supported_mime_types ); | |
| $supported_mime_types = (array) apply_filters( 'dominant_color_supported_mime_types', $supported_mime_types ); |
| ); | ||
|
|
||
| /** | ||
| * Filter supported mime types for dominant color extraction. |
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.
| * Filter supported mime types for dominant color extraction. | |
| * Filters supported mime types for dominant color extraction. |
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