PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 3.1.1
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v3.1.1
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 / width.php

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

63 lines 922 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Optml_Width
5 */
6 class Optml_Width extends Optml_Property_Type {
7
8 /**
9 * Width Property.
10 *
11 * @var mixed $width
12 */
13 private $width = 'auto';
14
15 /**
16 * Optml_Width constructor.
17 *
18 * @param mixed $value Default value.
19 */
20 public function __construct( $value ) {
21 $this->set( $value );
22 }
23
24 /**
25 * Set property value.
26 *
27 * @param mixed $value Value to set.
28 */
29 public function set( $value ) {
30
31 if ( $value === 'auto' ) {
32 $this->width = 'auto';
33
34 return;
35 }
36 if ( ! $this->is_valid_numeric( $value ) ) {
37 $this->width = 'auto';
38
39 return;
40 }
41
42 $this->width = $this->to_positive_integer( $value );
43 }
44
45 /**
46 * Return property value.
47 *
48 * @return mixed
49 */
50 public function get() {
51 return $this->width;
52 }
53
54 /**
55 * Return ImageProxy URL formatted string property.
56 *
57 * @return mixed
58 */
59 public function toString() {
60 return sprintf( 'w:%s', $this->width );
61 }
62 }
63