Skip to content

Added inline script to cleanup dominant color CSS variable on image load#2448

Open
Dhruval-678 wants to merge 4 commits intoWordPress:trunkfrom
Dhruval-678:issue/2432
Open

Added inline script to cleanup dominant color CSS variable on image load#2448
Dhruval-678 wants to merge 4 commits intoWordPress:trunkfrom
Dhruval-678:issue/2432

Conversation

@Dhruval-678
Copy link
Copy Markdown

@Dhruval-678 Dhruval-678 commented Apr 9, 2026

Summary

Fixes #2432

Changes

Added inline script to cleanup dominant color CSS variable on image load.
This script removes the --dominant-color CSS variable from images after they load,
preventing issues with dynamically loaded or lazily-loaded images.

Use of AI Tools

Clude code

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

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 props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @dhruval6781, @Dogway.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: dhruval6781, Dogway.

Co-authored-by: Dhruval-678 <dhruval04@git.wordpress.org>
Co-authored-by: b1ink0 <b1ink0@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@b1ink0 b1ink0 added [Plugin] Image Placeholders Issues for the Image Placeholders plugin (formerly Dominant Color Images) [Type] Bug An existing feature is broken labels Apr 9, 2026
@b1ink0 b1ink0 added this to the dominant-color-images n.e.x.t milestone Apr 9, 2026
Comment thread plugins/dominant-color-images/hooks.php Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.28%. Comparing base (8d1741e) to head (181ef03).

Files with missing lines Patch % Lines
plugins/dominant-color-images/hooks.php 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #2448      +/-   ##
==========================================
- Coverage   69.33%   69.28%   -0.06%     
==========================================
  Files          90       90              
  Lines        7749     7755       +6     
==========================================
  Hits         5373     5373              
- Misses       2376     2382       +6     
Flag Coverage Δ
multisite 69.28% <0.00%> (-0.06%) ⬇️
single 35.70% <0.00%> (-0.03%) ⬇️

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.

@b1ink0 b1ink0 requested a review from westonruter April 9, 2026 06:56
Comment thread plugins/dominant-color-images/hooks.php Outdated
{ capture: true },
);
JS;
wp_register_script( 'dominant-color-cleanup', false, array(), DOMINANT_COLOR_IMAGES_VERSION, true );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
wp_register_script( 'dominant-color-cleanup', false, array(), DOMINANT_COLOR_IMAGES_VERSION, true );
wp_register_script( 'dominant-color-cleanup', false, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion

IMO we don’t need to update the script version here. Versioning isn’t really necessary, and we can just pass null instead.

This is similar to how scripts are registered in the View Transitions plugin.

WDYT @westonruter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct. It is an inline script, so the version is not used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The sniff should be updated to not earn when null is used for a script with a false src, but that's out of scope here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mukeshpanchal27
Requested changes has been applied.

Kindly have a look.

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.

Image Placeholders not honoring image resizing

4 participants