PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 3.1.0
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v3.1.0
4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 3.12.1 All 134 releases
optimole-wp / inc / image_properties / quality.php

quality.php in Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization 3.1.0, at inc/image_properties/quality.php

79 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Optml_Quality
5 */
6 class Optml_Quality extends Optml_Property_Type {
7
8 /**
9 * Default quality value.
10 *
11 * @var string Quality value.
12 */
13 public static $default_quality = 'auto';
14 /**
15 * Quality Property.
16 *
17 * @var mixed $quality
18 */
19 private $quality;
20
21 /**
22 * Optml_Quality constructor.
23 *
24 * @param mixed $value Default value.
25 */
26 public function __construct( $value = '' ) {
27 if ( empty( $value ) ) {
28 $value = self::$default_quality;
29 }
30 $this->set( $value );
31 }
32
33 /**
34 * Set property value.
35 *
36 * @param mixed $value Value to set.
37 */
38 public function set( $value ) {
39
40 if ( $value === 'auto' ) {
41 $this->quality = 'auto';
42
43 return;
44 }
45 if ( $value === 'eco' ) {
46 $this->quality = 'eco';
47
48 return;
49 }
50
51 if ( ! $this->is_valid_numeric( $value ) ) {
52 $this->quality = 'auto';
53
54 return;
55 }
56
57 $this->quality = $this->to_bound_integer( $value, 0, 100 );
58
59 }
60
61 /**
62 * Return property value.
63 *
64 * @return mixed
65 */
66 public function get() {
67 return $this->quality;
68 }
69
70 /**
71 * Return ImageProxy URL formatted string property.
72 *
73 * @return mixed
74 */
75 public function toString() {
76 return sprintf( 'q:%s', $this->quality );
77 }
78 }
79