Extract colors from image assets in Craft 3.

Inner working

By using the imageColor field on each asset, it doesn't require extra database queries when showing colors. On install it creates a task to extract the color for every image.

Requirements

  • A field named imageColor on all assets of kind image (can be color or plaintext)
  • Craft 3 (we test on the latest release of Craft 3)
  • PHP 7.1 at least

Example usage

Use the colorExtractor twig filter to retrieve the image's color from templates.

<div style="background-color: {{ entry.images[0]|colorExtractor }};"></div>
Installation Instructions

To install this plugin, copy the command above to your terminal.

Active Installs
103
Version
3.0.0
License
MIT
Compatibility
Craft 3, Craft 4
Last release
December 5, 2022
Categories
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs