Skip to content

Conversation

@peterwilsoncc
Copy link
Contributor

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

$supported_mime_types = array(
	'image/jpeg',
	'image/png',
	'image/gif',
	'image/webp',
	'image/avif',
);

Introduces the filter dominant_color_supported_mime_types to allow third party developers to extend the feature.

Use of AI Tools

N/A

@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.89%. Comparing base (7938a41) to head (88a95a1).
⚠️ Report is 58 commits behind head on trunk.

Files with missing lines Patch % Lines
plugins/dominant-color-images/helper.php 90.00% 1 Missing ⚠️
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              
Flag Coverage Δ
multisite 68.89% <90.00%> (+0.02%) ⬆️
single 35.53% <90.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@westonruter westonruter added [Plugin] Image Placeholders Issues for the Image Placeholders plugin (formerly Dominant Color Images) [Type] Bug An existing feature is broken labels Dec 12, 2025
* 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
Copy link
Member

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.

Suggested change
* @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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For type safety.

Suggested change
$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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Filter supported mime types for dominant color extraction.
* Filters supported mime types for dominant color extraction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Image Placeholders Issues for the Image Placeholders plugin (formerly Dominant Color Images) [Type] Bug An existing feature is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Site crashes when uploading a video

2 participants