-
Notifications
You must be signed in to change notification settings - Fork 14
Improve quality setting handling in Compression settings #978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8d4376c
be3acff
b0c2099
1fe91ed
124434d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -75,7 +75,7 @@ class Optml_Settings { | |||||||||||||||||||||||||
| 'compression_mode' => 'custom', | ||||||||||||||||||||||||||
| 'cloud_sites' => [ 'all' => 'true' ], | ||||||||||||||||||||||||||
| 'watchers' => '', | ||||||||||||||||||||||||||
| 'quality' => 'auto', | ||||||||||||||||||||||||||
| 'quality' => 80, | ||||||||||||||||||||||||||
| 'wm_id' => - 1, | ||||||||||||||||||||||||||
| 'wm_opacity' => 1, | ||||||||||||||||||||||||||
| 'wm_position' => Position::SOUTH_EAST, | ||||||||||||||||||||||||||
|
|
@@ -237,7 +237,9 @@ public function auto_connect() { | |||||||||||||||||||||||||
| * @return array | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| public function parse_settings( $new_settings ) { | ||||||||||||||||||||||||||
| $sanitized = []; | ||||||||||||||||||||||||||
| $sanitized = []; | ||||||||||||||||||||||||||
| $sanitized_value = ''; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| foreach ( $new_settings as $key => $value ) { | ||||||||||||||||||||||||||
| switch ( $key ) { | ||||||||||||||||||||||||||
| case 'admin_bar_item': | ||||||||||||||||||||||||||
|
|
@@ -278,7 +280,9 @@ public function parse_settings( $new_settings ) { | |||||||||||||||||||||||||
| $sanitized_value = $this->to_bound_integer( $value, 100, 5000 ); | ||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||
| case 'quality': | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| case 'quality': | |
| case 'quality': | |
| // Minimum allowed quality was raised from 1 to 50. | |
| // Any previously stored values <50 will be coerced to 50 on next save. | |
| // Consider informing users who intentionally chose lower quality for stronger compression. | |
| if (intval($value) < 50) { | |
| // Optional: Log a warning or trigger a deprecation notice for legacy values. | |
| trigger_error( | |
| 'The minimum allowed image quality has been raised from 1 to 50. Values below 50 will be set to 50. Please review your settings.', | |
| E_USER_DEPRECATED | |
| ); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toggle handler (lines 106-117) writes 'mauto' into data.quality, but getQuality does not recognize 'mauto', only 'auto', so 'mauto' will fall through to the default branch (80) and any logic expecting a distinct auto sentinel may break or become ambiguous. Either change 'mauto' to 'auto' everywhere or add a condition for 'mauto' in getQuality (and any other downstream logic) to keep behavior consistent.