# optimole-wp/3.11.3/inc/image_properties/width.php

Optimole – Optimize Images | Convert WebP &amp; AVIF | CDN &amp; Lazy Load | Image Optimization, version 3.11.3. 63 lines.

- Page: https://pluginprobe.com/plugins/optimole-wp/3.11.3/code/inc/image_properties/width.php
- Raw: https://pluginprobe.com/plugins/optimole-wp/3.11.3/raw/inc/image_properties/width.php
- Modified: 2019-01-21T10:30:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/optimole-wp/3.11.3/code/inc/image_properties/width.php#L10-L20`.

```php
<?php

/**
 * Class Optml_Width
 */
class Optml_Width extends Optml_Property_Type {

	/**
	 * Width Property.
	 *
	 * @var mixed $width
	 */
	private $width = 'auto';

	/**
	 * Optml_Width constructor.
	 *
	 * @param mixed $value Default value.
	 */
	public function __construct( $value ) {
		$this->set( $value );
	}

	/**
	 * Set property value.
	 *
	 * @param mixed $value Value to set.
	 */
	public function set( $value ) {

		if ( $value === 'auto' ) {
			$this->width = 'auto';

			return;
		}
		if ( ! $this->is_valid_numeric( $value ) ) {
			$this->width = 'auto';

			return;
		}

		$this->width = $this->to_positive_integer( $value );
	}

	/**
	 * Return property value.
	 *
	 * @return mixed
	 */
	public function get() {
		return $this->width;
	}

	/**
	 * Return ImageProxy URL formatted string property.
	 *
	 * @return mixed
	 */
	public function toString() {
		return sprintf( 'w:%s', $this->width );
	}
}

```
