diff --git a/assets/src/dashboard/parts/connected/settings/Compression.js b/assets/src/dashboard/parts/connected/settings/Compression.js index 7ed554c8..9c432ee7 100644 --- a/assets/src/dashboard/parts/connected/settings/Compression.js +++ b/assets/src/dashboard/parts/connected/settings/Compression.js @@ -39,6 +39,30 @@ const Compression = ({ isSampleLoading, setIsSampleLoading }) => { + const getQuality = value => { + if ( 'number' === typeof value ) { + return value; + } + + if ( 'auto' === value || 'mauto' === value ) { + return 80; + } + + if ( 'high_c' === value ) { + return 90; + } + + if ( 'medium_c' === value ) { + return 75; + } + + if ( 'low_c' === value ) { + return 55; + } + + return 80; + }; + const { sampleImages, isLoading @@ -60,6 +84,7 @@ const Compression = ({ const isBestFormatEnabled = 'disabled' !== settings[ 'best_format' ]; const compressionMode = settings[ 'compression_mode' ]; const isRetinaEnabled = 'disabled' !== settings[ 'retina_images' ]; + const updateOption = ( option, value ) => { setCanSave( true ); const data = { ...settings }; @@ -79,30 +104,6 @@ const Compression = ({ ); }; - const getQuality = value => { - if ( 'number' === typeof value ) { - return value; - } - - if ( 'auto' === value ) { - return 90; - } - - if ( 'high_c' === value ) { - return 90; - } - - if ( 'medium_c' === value ) { - return 75; - } - - if ( 'low_c' === value ) { - return 55; - } - - return 90; - }; - const updateQuality = value => { setCanSave( true ); const data = { ...settings }; diff --git a/inc/settings.php b/inc/settings.php index 2c837641..c88e87be 100644 --- a/inc/settings.php +++ b/inc/settings.php @@ -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': - $sanitized_value = $this->to_bound_integer( $value, 1, 100 ); + if ( 'mauto' !== $value ) { + $sanitized_value = $this->to_bound_integer( $value, 50, 100 ); + } break; case 'wm_id': $sanitized_value = intval( $value );