Commit 4b36224
authored
Ability to convert images to next-gen formats (tinify#50)
* Add format options
* Add settings
* Add output examples
* Add mock responses
* Add file extension replacement
* Add conversion actions to compression clients
* Applied conversion
* Replace content with picture
* Import picture
* Add launch json for debugging
* Simplify conversion settings
* If original is already converted
* Show compression details
* Add constants
* Add conversion to fopen client
* reformat
* Use constant
* delete converted images
* Add settings test
* Replace labels
* Set correct mocks
* Format
* Add option to settings
* Add conversion test case
* get mimetype from input file
* Change register to register_once
* Add test case for convert and not replace
* Remove convert attribute
* Set callback after convert
* Add stream support
* Add unit cache to ignore
* Format
* Add tests for picture
* Will return array
* Change conditions to use non-constants
* Start of integration tests
* Support avif responses
* Remove replace
* Remove replace option
* remove replace from integration tests
* Change conversion settings
* Remove replace from integration test
* Remove convert options
* Remove convert options
* Format
* Change documentation
* Rename func to better indicate deleting size
* Basic conversion test
* Improve price explainer
* Calculate price for conversion as well
* Convert to static methods
* Add helpers
* Fix build
* Convert to static
* Add zip step
* fopen request should be a get
* Format
* Zip cmd
* Add xdebug for wordpress runner
* Use ABS_PATH instead of get_home_dir
* Remove get_home_path
* Inject allowed domains and base_dir
* Fix test
* Remove trailing commas
* Post unused
* Different method for retrieving image url
* Turn off conversion in bulk spec
* Format style
* format
* format
* Resolve int tests
* Change check method
* Skip welcome guide
* Use get_convert_format_option in get_conversion_enabled
* Add settings
* Compress and convert in one action
* Show conversions in summary
* Show statistics and convert button
* Show statistics for conversion
* Admin styling
* Change to public methods
* Replace picture by srcset and server side checking
* formatting
* format: yoda cond
* Ensure third param
* Use srcset instead of picture element
* format
* Format settings
* Format
* Format
* Add await to goto
* Fix typo
* Remove trailing komma
* No ??
* Format
* Get mimetypes from settings
* Double return + test fix
* Typos
* Change to picture element implementation
* Format
* Format
* Fix integration test
* Use array instead of []
* Use statistics for compressed total size
* Reduce MR size
* Use raw string instead of DOMDocument
* Remove debug script
* Format
* Format
* Rename statistic to compressed
* Add additiona table cells to match table size
* Only show columns when conversion is enabled
* Format
* Add emailadress to limit reached response
* Remove unneeded force click
* Check if resize_options has valid values
* It is possible to resize on only height or width
* Add a more performant way of clearing the media library
* Explicitly go to list view for attachments
* Null check on row
* Enhance conversion settings test utility
- Add support for output format selection (smallest, webp, avif)
- Remove force: true from checkbox interactions for more reliable tests
- Improve setConversionSettings function to handle different conversion formats
- Add switch statement to handle output format radio button selection
* Update conversion test to use explicit output format
- Add output: 'smallest' parameter to setConversionSettings call
- Ensures test uses the smallest file format conversion option
- Improves test clarity by being explicit about conversion settings
* Fix bulk optimization to include images needing conversion
- Fix bulk optimization logic to include already compressed images that need conversion
- Update available-for-optimization array to consider both compression and conversion needs
- Enhance bulk optimization JavaScript to properly display compression and conversion results
- Add comprehensive test for conversion-only optimization scenario
This ensures that when conversion is enabled, bulk optimization will process:
1. Uncompressed images (compression + conversion)
2. Already compressed images that need conversion (conversion only)
Previously, already compressed images were excluded from bulk optimization
even when they needed conversion, causing incomplete optimization runs.
* Update bulk optimization UI text to reflect optimization instead of compression
- Change 'activated for compression' to 'activated for optimization'
- Change 'is compressed' to 'is optimized' in size count messages
- Better reflects that bulk optimization now handles both compression and conversion
- Improves user understanding of the feature scope
* Fix bulk optimization logic to handle both compression and conversion
- Fix available-for-optimization condition to check both uncompressed and unconverted sizes
- Separate uncompressed and unconverted size filtering when conversion is enabled
- Ensure compressed images can still be converted when conversion feature is toggled on
- Update test to properly verify optimization statistics with conversion scenarios
- Add test coverage for compressed images being eligible for conversion
This resolves issues where already compressed images weren't being converted
when users enabled the conversion feature after initial compression.
* Format
* Format
* Refactor: rename parameter in estimate_cost for clarity
Rename 'usage' parameter to 'compressions_used' in estimate_cost method
to better reflect its purpose and improve code readability.
* Refactor: extract bulk cost estimation logic and add tests
- Move Tiny_Picture initialization to init() method for better lifecycle management
- Extract get_estimated_bulk_cost() method from render_bulk_optimization_page()
to improve code organization and testability
- Add comprehensive unit tests for bulk cost estimation scenarios:
- Basic cost calculation without conversion
- Cost calculation with format conversion enabled
- Improve code readability and maintainability
* Format
* test: enhance TinyPluginTest with comprehensive test coverage
- Add tests for plugin initialization and configuration
- Improve test structure and assertions
- Expand test cases to cover more functionality
* feat: add credit usage tracking for bulk optimization cost calculation
- Add estimated_credit_use statistic to track compression credits needed
- Update cost calculation to use accurate credit estimates instead of simple multiplication
- Handle conversion scenarios properly:
* Uncompressed images needing compression + conversion = 2 credits each
* Compressed images needing only conversion = 1 credit each
- Fix null handling for tiny_meta_value in bulk optimization statistics
- Update tests to reflect accurate credit calculations and expectations
This change provides more precise cost estimates for bulk optimization by
tracking actual credit usage based on image compression and conversion states.
* Format1 parent 724cad2 commit 4b36224
File tree
43 files changed
+2201
-339
lines changed- .vscode
- src
- css
- js
- views
- test
- fixtures
- helpers
- integration
- mock-tinypng-webservice
- unit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
43 files changed
+2201
-339
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
| 104 | + | |
102 | 105 | | |
103 | 106 | | |
104 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
| |||
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
| 122 | + | |
117 | 123 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
121 | 138 | | |
122 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
123 | 144 | | |
124 | 145 | | |
125 | 146 | | |
126 | 147 | | |
127 | 148 | | |
128 | | - | |
| 149 | + | |
| 150 | + | |
129 | 151 | | |
130 | 152 | | |
131 | 153 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
| 106 | + | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
111 | | - | |
| 110 | + | |
112 | 111 | | |
113 | 112 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | | - | |
123 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
124 | 137 | | |
| 138 | + | |
125 | 139 | | |
126 | 140 | | |
127 | 141 | | |
| |||
130 | 144 | | |
131 | 145 | | |
132 | 146 | | |
133 | | - | |
| 147 | + | |
134 | 148 | | |
135 | 149 | | |
136 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
149 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
150 | 177 | | |
151 | 178 | | |
152 | 179 | | |
| |||
188 | 215 | | |
189 | 216 | | |
190 | 217 | | |
191 | | - | |
192 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
193 | 222 | | |
194 | 223 | | |
195 | 224 | | |
| |||
221 | 250 | | |
222 | 251 | | |
223 | 252 | | |
224 | | - | |
| 253 | + | |
225 | 254 | | |
226 | 255 | | |
227 | 256 | | |
228 | | - | |
| 257 | + | |
229 | 258 | | |
230 | 259 | | |
231 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
| 44 | + | |
44 | 45 | | |
45 | | - | |
46 | | - | |
| 46 | + | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
96 | 111 | | |
97 | 112 | | |
98 | 113 | | |
| |||
110 | 125 | | |
111 | 126 | | |
112 | 127 | | |
113 | | - | |
114 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
115 | 132 | | |
116 | | - | |
| 133 | + | |
| 134 | + | |
117 | 135 | | |
118 | 136 | | |
119 | 137 | | |
120 | 138 | | |
121 | 139 | | |
122 | 140 | | |
123 | | - | |
124 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
125 | 160 | | |
126 | 161 | | |
127 | 162 | | |
128 | 163 | | |
129 | 164 | | |
| 165 | + | |
| 166 | + | |
130 | 167 | | |
131 | 168 | | |
132 | 169 | | |
133 | 170 | | |
134 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
135 | 177 | | |
136 | 178 | | |
137 | 179 | | |
| |||
150 | 192 | | |
151 | 193 | | |
152 | 194 | | |
153 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
154 | 201 | | |
155 | 202 | | |
156 | 203 | | |
| |||
0 commit comments