ImageOptions
class ImageOptions implements UrlOptionsInterface
ImageOptions class.
This class allows specifying extended options to the Contentful Image API, to resize images or change their format.
Methods
The urlencoded query string for these options.
Set the width of the image.
Set the height of the image.
Set the format of the image. Valid values are "png" and "jpg".
Quality of the JPEG encoded image.
Set to true to load the image as a progressive JPEG.
Set to true to load the image as a 8-bit PNG.
Change the behavior when resizing the image.
Set the focus area when the resize fit is set to 'thumb'.
Add rounded corners to your image or crop to a circle/ellipsis.
Background color, relevant if the resize fit type 'pad' is used.
Details
at line 77
getQueryString()
The urlencoded query string for these options.
at line 132
$this
setWidth(int $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 158
$this
setHeight(int $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 177
$this
setFormat(string $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 200
$this
setQuality(int $quality = null)
Quality of the JPEG encoded image.
The image format will be forced to JPEG.
at line 217
$this
setProgressive(bool $progressive)
Set to true to load the image as a progressive JPEG.
The image format will be forced to JPEG.
at line 230
$this
setPng8Bit(bool $png8Bit)
Set to true to load the image as a 8-bit PNG.
The image format will be forced to PNG.
at line 255
$this
setResizeFit(string $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 280
$this
setResizeFocus(string $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 314
$this
setRadius(float $radius = null)
Add rounded corners to your image or crop to a circle/ellipsis.
at line 333
$this
setBackgroundColor(string $backgroundColor = null)
Background color, relevant if the resize fit type 'pad' is used.
Expects a valid hexadecimal HTML color like '#9090ff'. Default is transparency.