ImageOptions
class ImageOptions
ImageOptions allows specifying extended options to the Contentful Image API .
to resize images or change their format.
Methods
ImageOptions constructor.
The urlencoded query string for these options.
Get the width of the image. Will be null if no width is set.
Set the width of the image.
Get the height of the image. Will be null if no height is set.
Set the height of the image.
Format of the image. Possible values are "png" and "jpg". Will be null if no format is set.
Set the format of the image. Valid values are "png" and "jpg". Can be set to null to not enforce a format.
Quality of the JPEG encoded image. Will be null if no quality is set.
Quality of the JPEG encoded image.
Returns true if the image will be loaded as progressive JPEG.
Set to true to load the image as a progressive JPEG.
Returns the behavior used for resizing images.
Change the behavior when resizing the image.
Get the focus area for resizing.
Set the focus area when the resize fit is set to 'thumb'.
Radius used to crop the image.
Add rounded corners to your image or crop to a circle/ellipsis.
Returns the background color used when padding an image.
Background color, relevant if the resize fit type 'pad' is used.
Details
at line 73
__construct()
ImageOptions constructor.
Empty, only included for forward compatibility.
at line 82
string
getQueryString()
The urlencoded query string for these options.
at line 117
int|null
getWidth()
Get the width of the image. Will be null if no width is set.
at line 136
$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.
at line 152
int|null
getHeight()
Get the height of the image. Will be null if no height is set.
at line 171
$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.
at line 187
string|null
getFormat()
Format of the image. Possible values are "png" and "jpg". Will be null if no format is set.
at line 205
$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.
at line 223
int|null
getQuality()
Quality of the JPEG encoded image. Will be null if no quality is set.
at line 239
$this
setQuality(int|null $quality = null)
Quality of the JPEG encoded image.
The image format will be forced to JPEG.
at line 255
bool
isProgressive()
Returns true if the image will be loaded as progressive JPEG.
at line 269
$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.
at line 281
null|string
getResizeFit()
Returns the behavior used for resizing images.
at line 306
$this
setResizeFit(string|null $resizeFit = null)
Change the behavior when resizing the image.
By default, images are resized to fit inside the bounding box set trough setWidth and setHeight while retaining their aspect ratio.
Possible values are: - null for the default value - 'pad' Same as the default, but add padding so that the generated image has exactly the given dimensions. - 'crop' Crop a part of the original image. - 'fill' Fill the given dimensions by cropping the image. - 'thumb' Create a thumbnail of detected faces from image, used with 'setFocus'. - 'scale' Scale the image regardless of the original aspect ratio.
at line 324
string|null
getResizeFocus()
Get the focus area for resizing.
at line 343
$this
setResizeFocus(string|null $resizeFocus = null)
Set the focus area when the resize fit is set to 'thumb'.
Possible values are: - 'top', 'right', 'left', 'bottom' - A combination like 'bottom_right' - 'face' or 'faces' to focus the resizing via face detection
at line 361
float|null
getRadius()
Radius used to crop the image.
at line 375
$this
setRadius(float|null $radius = null)
Add rounded corners to your image or crop to a circle/ellipsis.
at line 391
string|null
getBackgroundColor()
Returns the background color used when padding an image.
at line 407
$this
setBackgroundColor(string|null $backgroundColor = null)
Background color, relevant if the resize fit type 'pad' is used.
Expects a valid hexadecimal HTML color like '#9090ff'. Default is transparency.