ImageUtil
in package
Table of Contents
Properties
- $container : ContainerInterface
- $framework : ContaoFramework
Methods
- __construct() : mixed
- addToTemplateData() : mixed
- Add an image to a template.
- getPixelValue() : int
- Convert sizes like 2em, 10cm or 12pt to pixels.
- prepareImage() : array<string|int, mixed>
- Prepares one image for a typical Contao template.
Properties
$container
protected
ContainerInterface
$container
$framework
protected
ContaoFramework
$framework
Methods
__construct()
public
__construct(ContainerInterface $container) : mixed
Parameters
- $container : ContainerInterface
addToTemplateData()
Add an image to a template.
public
addToTemplateData(string $imageField, string $imageSelectorField, array<string|int, mixed> &$templateData, array<string|int, mixed> $item[, int|null $maxWidth = null ][, string|null $lightboxId = null ][, string|null $lightboxName = null ][, FilesModel|null $model = null ]) : mixed
Advanced version of Controller::addImageToTemplate with custom imageField and imageSelectorField and array instead of FrontendTemplate.
Parameters
- $imageField : string
-
the image field name (typical singleSRC)
- $imageSelectorField : string
-
the image selector field indicated if an image is added (typical addImage)
- $templateData : array<string|int, mixed>
-
An array to add the generated data to
- $item : array<string|int, mixed>
-
The source data containing the imageField and imageSelectorField
- $maxWidth : int|null = null
-
An optional maximum width of the image
- $lightboxId : string|null = null
-
An optional lightbox ID
- $lightboxName : string|null = null
-
An optional lightbox name
- $model : FilesModel|null = null
-
an optional file model used to read meta data
getPixelValue()
Convert sizes like 2em, 10cm or 12pt to pixels.
public
getPixelValue(string $size) : int
Parameters
- $size : string
-
The size string
Return values
int —The pixel value
prepareImage()
Prepares one image for a typical Contao template.
public
prepareImage(array<string|int, mixed> $data[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Possible option keys:
- imageField: (string) The name of the field containers the image uuid. Default: singleSRC
- imageSelectorField: (?string) The name of the field that indicated if an images is added. Set to null to skip check. Default: addImage
- maxWidth: (int) An optional maximum width of the image. Passed directly to Controller::addImageToTemplate()
- lightboxId: (string) An optional lightbox ID. Passed directly to Controller::addImageToTemplate()
Parameters
- $data : array<string|int, mixed>
-
the model/module/element data
- $options : array<string|int, mixed> = []
-
Additional options