class ImageOptions

ImageOptions allows specifying extended options to the Contentful Image API .

to resize images or change their format.

Methods

__construct()

ImageOptions constructor.

string
getQueryString()

The urlencoded query string for these options.

int|null
getWidth()

Get the width of the image. Will be null if no width is set.

$this
setWidth(int|null $width = null)

Set the width of the image.

int|null
getHeight()

Get the height of the image. Will be null if no height is set.

$this
setHeight(int|null $height = null)

Set the height of the image.

string|null
getFormat()

Format of the image. Possible values are "png" and "jpg". Will be null if no format is set.

$this
setFormat(string|null $format = null)

Set the format of the image. Valid values are "png" and "jpg". Can be set to null to not enforce a format.

int|null
getQuality()

Quality of the JPEG encoded image. Will be null if no quality is set.

$this
setQuality(int|null $quality = null)

Quality of the JPEG encoded image.

bool
isProgressive()

Returns true if the image will be loaded as progressive JPEG.

$this
setProgressive(bool|null $progressive = null)

Set to true to load the image as a progressive JPEG.

Details

at line 51
__construct()

ImageOptions constructor.

Empty, only included for forward compatibility.

at line 62
string getQueryString()

The urlencoded query string for these options.

Return Value

string

at line 88
int|null getWidth()

Get the width of the image. Will be null if no width is set.

Return Value

int|null

at line 109
$this setWidth(int|null $width = null)

Set the width of the image.

The image will by default not be stretched, skewed or enlarged. Instead it will be fit into the bounding box given by the width and height parameters.

Can be set to null to not set a width.

Parameters

int|null $width The width in pixel.

Return Value

$this

Exceptions

InvalidArgumentException If $width is negative

at line 127
int|null getHeight()

Get the height of the image. Will be null if no height is set.

Return Value

int|null

at line 148
$this setHeight(int|null $height = null)

Set the height of the image.

The image will by default not be stretched, skewed or enlarged. Instead it will be fit into the bounding box given by the width and height parameters.

Can be set to null to not set a height.

Parameters

int|null $height The height in pixel.

Return Value

$this

Exceptions

InvalidArgumentException If $height is negative

at line 166
string|null getFormat()

Format of the image. Possible values are "png" and "jpg". Will be null if no format is set.

Return Value

string|null

at line 186
$this setFormat(string|null $format = null)

Set the format of the image. Valid values are "png" and "jpg". Can be set to null to not enforce a format.

Parameters

string|null $format

Return Value

$this

Exceptions

InvalidArgumentException If $format is not a valid value

at line 206
int|null getQuality()

Quality of the JPEG encoded image. Will be null if no quality is set.

Return Value

int|null If an int, must be between 1 and 100.

at line 224
$this setQuality(int|null $quality = null)

Quality of the JPEG encoded image.

The image format will be forced to JPEG.

Parameters

int|null $quality If an int, between 1 and 100.

Return Value

$this

Exceptions

InvalidArgumentException If $quality is out of range

at line 242
bool isProgressive()

Returns true if the image will be loaded as progressive JPEG.

Return Value

bool

at line 256
$this setProgressive(bool|null $progressive = null)

Set to true to load the image as a progressive JPEG.

The image format will be forced to JPEG.

Parameters

bool|null $progressive

Return Value

$this