-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
161 lines (101 loc) · 5.17 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Dominant color async
Contributors: joppuyo
Tags: dominant, color, asynchronous
Requires at least: 5.0
Tested up to: 5.8
Requires PHP: 7.0.0
License: GPLv2 or later
Calculate the dominant color for every image in WordPress, asynchronously
## Description
Dominant color async calculates the dominant color for images in your WordPress media gallery. It will also tell you if your image has transparency, or not. You can access this information using the `dca_get_image_dominant_color` and `dca_get_image_transparency` filters. This information will be calculated after you upload images in the media gallery.
### Getting dominant color
```php
$image_id = 123;
// Returns a hex code string or null if dominant color hasn't been calculated yet
$dominant_color = apply_filters('dca_get_dominant_color', null, $image_id);
if ($dominant_color !== null) {
echo "Image dominant color: " . $dominant_color;
} else if ($dominant_color === null) {
echo "Image dominant color hasn't been calculated yet.";
}
```
### Getting transparency
```php
$image_id = 123;
// Returns either true, false or null if transparency hasn't been calculated yet
$has_transparency = apply_filters('dca_get_transparency', null, $image_id);
// Note: use strict comparison here instead of a shorthand to differentiate between false and null
if ($has_transparency === true) {
echo "Image has transparency";
} else if ($has_transparency === false) {
echo "Image doesn't have transparency";
} else if ($has_transparency === null) {
echo "Image transparency hasn't been calculated yet.";
}
```
## Installation
1. Upload the plugin folder to the /wp-content/plugins/ directory
2. Activate the plugin through the Plugins menu in WordPress
## Frequently Asked Questions
### How is this different from Dominant Color plugin?
[Dominant Color](https://wordpress.org/plugins/dominant-color/) calculates the dominant color synchronously as you are uploading them. This can sometimes take a long time and lead to frustrating experience. Dominant color async will do this processing in the background using [Action Scheduler](https://actionscheduler.org/) library, leading to more fluid admin experience.
Dominant color async will also allow you to calculate color information for images missing it as a batch process. This makes it easy to integrate the plugin into an existing site.
One thing missing from this plugin is the "palette" functionality of Dominant Color which generates multiple dominant colors for single image and allows you to pick from one of these. If you need this functionality, then Dominant Color is a better choice.
### How can I report an issue or contribute code?
Please report issues and send pull requests on the [GitHub repo](https://github.com/CreunaFI/dominant-color-async).
## Changelog
### 2.1.0
* Feature: Add filters for getting dominant color and transparency
* Fix: Fix error when ImageMagick is installed but GD is not
* Fix: Updated compatibility to WordPress 5.8
### 2.0.4
* Fix: Update dependencies, again
### 2.0.3
* Fix: Update dependencies
### 2.0.2
* Fix: Add an admin notice instead of crashing if dependencies are missing
### 2.0.1
* Fix: Fix fatal error due to wrong dependency version
### 2.0.0
* Breaking change: Minimum supported PHP version is now 7.0
* Breaking change: Minimum supported WordPress version is now 5.0
* Breaking change: Support for Packagist has been removed since Packagist does not support compiled assets like JavaScript or CSS unless they are committed to the Git repository. Please download the latest release from GitHub releases. Auto-updater is included in the plugin. If you need install the plugin using Composer, set up your own [SatisPress](https://github.com/cedaro/satispress) repository.
* Fix: Don't show dominant color field on attachments that are not images
* Change: Changed library used for async processing to woocommerce/action-scheduler instead of deliciousbrains/wp-background-processing since Action Scheduler is more actively supported and it handles large amount of actions better
### 1.1.3
* Fix: Make query more efficient
### 1.1.2
* Fix: Fix build
### 1.1.1
* Fix: Fix build
### 1.1.0
* Feature: Save image hash in the database and skip processing the image if it has not changed
* Fix: Fix issue where image with only one field processed does not show up as unprocessed
### 1.0.11
* Fix: Fix issue where failed image processing can cause an infinite loop
* Fix: Bump supported WordPress version to 5.1
### 1.0.10
* When processing all unprocessed images, chunk batches to avoid timeout on some servers
### 1.0.9
* Check attachment exists before processing
* Install dependencies according to minimum PHP version requirements
### 1.0.8
* Update PHP requirement information
### 1.0.7
* Move var-dumper to dev dependencies
### 1.0.6
* Add Bedrock support
### 1.0.5
* Fix imagick support
### 1.0.4
* Use imagick if gd is not loaded
### 1.0.3
* Fix settings button path
* Improve dominant color calculation accuracy
### 1.0.2
* Update composer.json
### 1.0.1
* Update package.json
### 1.0.0
* Initial release