Skip to content

Commit 7384082

Browse files
committed
set values on or off only
1 parent cd86e69 commit 7384082

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

php/class-media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ public function default_image_transformations( $default ) {
773773

774774
$config = $this->settings->get_value( 'image_settings' );
775775

776-
if ( true === $config['image_optimization'] ) {
776+
if ( 'on' === $config['image_optimization'] ) {
777777
if ( 'auto' === $config['image_format'] ) {
778778
$default['fetch_format'] = 'auto';
779779
}

php/ui/component/class-on-off.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function false_value( $struct ) {
3333
$struct['element'] = 'input';
3434
$struct['attributes']['type'] = 'hidden';
3535
$struct['attributes']['name'] = $this->get_name();
36-
$struct['attributes']['value'] = false;
36+
$struct['attributes']['value'] = 'off';
3737
unset( $struct['attributes']['class'] );
3838
unset( $struct['attributes']['data-bound'] );
3939
$struct['render'] = true;
@@ -54,8 +54,8 @@ protected function input( $struct ) {
5454
$struct['attributes']['type'] = 'checkbox';
5555
$struct['attributes']['name'] = $this->get_name();
5656
$struct['attributes']['id'] = $this->setting->get_slug();
57-
$struct['attributes']['value'] = true;
58-
if ( $this->setting->get_value() ) {
57+
$struct['attributes']['value'] = 'on';
58+
if ( 'true' === $this->setting->get_value() ) {
5959
$struct['attributes']['checked'] = 'checked';
6060
}
6161
$struct['attributes']['class'] = 'cld-ui-input';
@@ -106,6 +106,6 @@ protected function slider( $struct ) {
106106
* @return bool
107107
*/
108108
public function sanitize_value( $value ) {
109-
return (bool) $value;
109+
return 'on' === $value ? 'on' : 'off';
110110
}
111111
}

ui-definitions/settings-image.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
'title' => __( 'Image optimization', 'cloudinary' ),
2626
'tooltip_text' => __( 'Images will be delivered using Cloudinary’s automatic format and quality algorithms for the best tradeoff between visual quality and file size. Use Advanced Optimization options to manually tune format and quality.', 'cloudinary' ),
2727
'description' => __( 'Optimize images on my site.', 'cloudinary' ),
28-
'default' => true,
28+
'default' => 'on',
2929
'attributes' => array(
3030
'data-context' => 'image',
3131
),
3232
),
33-
3433
),
3534
array(
3635
'type' => 'group',

ui-definitions/settings-video.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
'slug' => 'video_loop',
4747
'description' => __( ' Repeat video', 'cloudinary' ),
4848
'type' => 'on_off',
49-
'default' => false,
49+
'default' => 'off',
5050
),
5151
array(
5252
'slug' => 'video_autoplay_mode',
@@ -72,7 +72,7 @@
7272
'title' => __( 'Bitrate', 'cloudinary' ),
7373
'description' => __( 'Enable bitrate limiter', 'cloudinary' ),
7474
'tooltip_text' => __( 'If set, all videos will be delivered in the defined bitrate.', 'cloudinary' ),
75-
'default' => false,
75+
'default' => 'off',
7676
'attributes' => array(
7777
'data-context' => 'video',
7878
),
@@ -102,7 +102,7 @@
102102
'title' => __( 'Video optimization', 'cloudinary' ),
103103
'tooltip_text' => __( 'Videos will be delivered using Cloudinary’s automatic format and quality algorithms for the best tradeoff between visual quality and file size. Use Advanced Optimization options to manually tune format and quality.', 'cloudinary' ),
104104
'description' => __( 'Optimize videos on my site.', 'cloudinary' ),
105-
'default' => true,
105+
'default' => 'on',
106106
'attributes' => array(
107107
'data-context' => 'video',
108108
),

0 commit comments

Comments
 (0)