Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions php/class-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ public function default_image_transformations( $default ) {

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

if ( true === $config['image_optimization'] ) {
if ( 'on' === $config['image_optimization'] ) {
if ( 'auto' === $config['image_format'] ) {
$default['fetch_format'] = 'auto';
}
Expand Down Expand Up @@ -1145,7 +1145,7 @@ public function image_srcset( $sources, $size_array, $image_src, $image_meta, $a

$image_meta['overwrite_transformations'] = ! empty( $image_meta['overwrite_transformations'] ) ? $image_meta['overwrite_transformations'] : false;

if ( $this->settings->get_setting( 'enable_breakpoints' )->get_value() && wp_image_matches_ratio( $image_meta['width'], $image_meta['height'], $size_array[0], $size_array[1] ) ) {
if ( 'on' === $this->settings->get_setting( 'enable_breakpoints' )->get_value() && wp_image_matches_ratio( $image_meta['width'], $image_meta['height'], $size_array[0], $size_array[1] ) ) {
$meta = $this->get_post_meta( $attachment_id, Sync::META_KEYS['breakpoints'], true );
if ( ! empty( $meta ) ) {
// Since srcset is primary and src is a fallback, we need to set the first srcset with the main image.
Expand Down Expand Up @@ -1718,7 +1718,7 @@ public function get_breakpoint_options( $attachment_id ) {
$breakpoints = array();
$settings = $this->settings->get_setting( self::MEDIA_SETTINGS_SLUG )->get_value();

if ( ! empty( $settings['enable_breakpoints'] ) && wp_attachment_is_image( $attachment_id ) ) {
if ( 'on' === $settings['enable_breakpoints'] && wp_attachment_is_image( $attachment_id ) ) {
$meta = wp_get_attachment_metadata( $attachment_id );
// Get meta image size if non exists.
if ( empty( $meta ) ) {
Expand Down
4 changes: 2 additions & 2 deletions php/media/class-video.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@ public function filter_video_block_pre_render( $block, $source_block ) {
*/
public function default_video_transformations( $default ) {

if ( ! empty( $this->config['video_limit_bitrate'] ) ) {
if ( 'on' === $this->config['video_limit_bitrate'] ) {
$default['bit_rate'] = $this->config['video_bitrate'] . 'k';
}
if ( ! empty( $this->config['video_optimization'] ) && true === $this->config['video_optimization'] ) {
if ( 'on' === $this->config['video_optimization'] ) {
if ( 'auto' === $this->config['video_format'] ) {
$default['fetch_format'] = 'auto';
}
Expand Down
2 changes: 1 addition & 1 deletion php/sync/class-upload-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public function explicit_update( $attachment_id ) {
*/
public function update_breakpoints( $attachment_id, $breakpoints ) {

if ( ! empty( $this->plugin->settings->get_value( 'enable_breakpoints' ) ) ) {
if ( 'on' === $this->plugin->settings->get_value( 'enable_breakpoints' ) ) {
if ( ! empty( $breakpoints['responsive_breakpoints'] ) ) { // Images only.
$this->media->update_post_meta( $attachment_id, Sync::META_KEYS['breakpoints'], $breakpoints['responsive_breakpoints'][0]['breakpoints'] );
} elseif ( wp_attachment_is_image( $attachment_id ) ) {
Expand Down
8 changes: 4 additions & 4 deletions php/ui/component/class-on-off.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function false_value( $struct ) {
$struct['element'] = 'input';
$struct['attributes']['type'] = 'hidden';
$struct['attributes']['name'] = $this->get_name();
$struct['attributes']['value'] = false;
$struct['attributes']['value'] = 'off';
unset( $struct['attributes']['class'] );
unset( $struct['attributes']['data-bound'] );
$struct['render'] = true;
Expand All @@ -54,8 +54,8 @@ protected function input( $struct ) {
$struct['attributes']['type'] = 'checkbox';
$struct['attributes']['name'] = $this->get_name();
$struct['attributes']['id'] = $this->setting->get_slug();
$struct['attributes']['value'] = true;
if ( $this->setting->get_value() ) {
$struct['attributes']['value'] = 'on';
if ( 'on' === $this->setting->get_value() ) {
$struct['attributes']['checked'] = 'checked';
}
$struct['attributes']['class'] = 'cld-ui-input';
Expand Down Expand Up @@ -106,6 +106,6 @@ protected function slider( $struct ) {
* @return bool
*/
public function sanitize_value( $value ) {
return (bool) $value;
return 'on' === $value ? 'on' : 'off';
}
}
4 changes: 2 additions & 2 deletions ui-definitions/settings-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
'title' => __( 'Image optimization', 'cloudinary' ),
'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' ),
'description' => __( 'Optimize images on my site.', 'cloudinary' ),
'default' => true,
'default' => 'on',
'attributes' => array(
'data-context' => 'image',
),
),

),
array(
'type' => 'group',
Expand Down Expand Up @@ -92,6 +91,7 @@
'title' => __( 'Image breakpoints', 'cloudinary' ),
'tooltip_text' => __( 'Automatically generate multiple sizes based on the configured breakpoints to enable your images to responsively adjust to different screen sizes. Note that your Cloudinary usage will increase when enabling responsive images.', 'cloudinary' ),
'description' => __( 'Enable responsive images.', 'cloudinary' ),
'default' => 'off',
),
array(
'type' => 'group',
Expand Down
10 changes: 5 additions & 5 deletions ui-definitions/settings-video.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
'slug' => 'video_loop',
'description' => __( ' Repeat video', 'cloudinary' ),
'type' => 'on_off',
'default' => false,
'default' => 'off',
),
array(
'slug' => 'video_autoplay_mode',
Expand All @@ -72,7 +72,7 @@
'title' => __( 'Bitrate', 'cloudinary' ),
'description' => __( 'Enable bitrate limiter', 'cloudinary' ),
'tooltip_text' => __( 'If set, all videos will be delivered in the defined bitrate.', 'cloudinary' ),
'default' => false,
'default' => 'off',
'attributes' => array(
'data-context' => 'video',
),
Expand All @@ -85,7 +85,7 @@
'default' => '500',
'suffix' => 'k',
'condition' => array(
'video_limit_bitrate' => true,
'video_limit_bitrate' => 'on',
),
'attributes' => array(
'data-context' => 'video',
Expand All @@ -102,7 +102,7 @@
'title' => __( 'Video optimization', 'cloudinary' ),
'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' ),
'description' => __( 'Optimize videos on my site.', 'cloudinary' ),
'default' => true,
'default' => 'on',
'attributes' => array(
'data-context' => 'video',
),
Expand All @@ -113,7 +113,7 @@
'title' => __( 'Advanced optimization', 'cloudinary' ),
'collapsible' => 'open',
'condition' => array(
'video_optimization' => true,
'video_optimization' => 'on',
),
array(
'type' => 'select',
Expand Down