born05 / craft-colorextractor
Extract colors from image assets in Craft CMS. Requires a field named `imageColor` on all assets of kind image (can be color or plaintext)
Installs: 5 079
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 8
Forks: 5
Open Issues: 0
Type:craft-plugin
Requires
- php: ^8.0.2
- craftcms/cms: ^4.0.0-alpha
- ksubileau/color-thief-php: ^2.0
This package is auto-updated.
Last update: 2024-06-05 11:13:39 UTC
README
Extract colors from image assets in Craft 3. The Craft 2 plugin is moved to another branch.
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>
From command:
craft color-extractor/default
License
Copyright © Born05
See license
Credits
Based upon craft-image-color plugin by familiar-studio.