Helper class: Imengine
This class generates correct urls for the service Imengine. It helps you to add the appropriate parameters to generate images according to you needs.
Full name: \Infomaker\Imengine\Imengine
Setup and configuration
This class needs an Imengine to build correct urls. To set the correct Imengine you use the setup method:
Parameters:
Parameter | Type | Description |
| string | The Imengine url to base all built request-urls. |
Setup and configuration from Base theme
This is done setup from the ThemeStartup
. The Imengine server
is configured in the Everyware plugin under Open Content->OC Settings
in wp-admin
.
To set the Imengine server
url on a network level use the variable CF_IMENGINE
in the .env
-file. This will be used as default if the server has not been configured in the OC Settings
example:
Standard usage
The class is used as a static instance. You create an instance through one of the static functions found bellow.
Required methods:
We have two available ways to specify the src of the image. For this we use one of the following methods:
fromUuid
Defines what src that Imengine will manipulate
Parameters:
Parameter | Type | Description |
| string | The uuid of the image in Open Content. |
fromSrc
Defines what src that Imengine will manipulate
Parameters:
Parameter | Type | Description |
| string | The url to an external image. |
Example:
Static functions
create
Create url from scratch by using parameters provided
Parameters:
Parameter | Type | Description |
| array | Optional. Parameters to send forth to the Imengine url (default=null) |
createMirrorFunction
Create an instance with only the function to mirror and params. This method is used by all static functions to mirror Imengine server-functions.
Parameters:
Parameter | Type | Description |
| string | The Imengine server-function to use |
| array | Optional. Parameters to send forth to the Imengine url (default=null) |
Mirrored functions
These static methods are used to instantiate the Imengine class. They mirror the functions found on Imengine API
cover
Uses the original image ratio and customize the width or height to scale image within the specified limits.
Parameters:
Parameter | Type | Description |
| int | Optional. limits the width to amount in pixels (default=null) |
| int | Optional. limits the height to amount in pixels (default=null) |
cropResize
Crop image into defined crop-size from custom start-positions. Then scale into defined size.
Uses: \Infomaker\Imengine\CropData\Interfaces\CropResizeDataInterface
Parameters:
Parameter | Type | Description |
| CropResizeDataInterface | An interface from where the necessary data can be extracted. |
fit
Scale image to fit inside the limits. Add scale up to make the image cover the maxsize-area (Can exceed limits on scale up)
Parameters:
Parameter | Type | Description |
| int | The limits to for height and width |
| boolean | Optional. Whether to make the resulted image cover the maxsize-area. This option can exceed limits. (default=TRUE) |
hardcrop
Crop image into defined size top left position
Parameters:
Parameter | Type | Description |
| int | Resulted width |
| int | Resulted height |
newsPilotCrop
Crop image into defined size from custom start-positions. Implemented as crop for NewsPilot
Uses: \Infomaker\Imengine\CropData\Interfaces\NewsPilotCropDataInterface
Parameters:
Parameter | Type | Description |
| NewsPilotCropDataInterface | An interface from where the necessary data can be extracted. |
original
Fetch image with original size.
Parameters: No parameters
thumbnail
Crop image into defined size from center position
Parameters:
Parameter | Type | Description |
| int | Resulted width |
| int | Resulted height |
ratio
Crop image into given ratio using "hardcrop".
Parameter | Type | Description |
| int | Resulted width |
| string | Optional. The ratio from which to calculate the height. (default='3:2') |
autoCrop
Crop image into given ratio from center. Uses the original sizes of the image to calculate the values needed for "cropresize"
Uses: \Infomaker\Imengine\CropData\Interfaces\AutoCropDataInterface
Parameters:
Parameter | Type | Description |
| AutoCropDataInterface | An interface from where the necessary data can be extracted. |
square
Crop image into a square using "hardcrop".
Parameters:
Parameter | Type | Description |
| int | Resulted height and width |
raw
Function for fetching the Raw format of the image (May have an unlimited size) This function is only available for images from Open Content.
Parameters:
Parameter | Type | Description |
| string | The uuid of the |
| int | Optional. The quality in percent of the resulted image. (default=100) |
Chainable functions
These functions add options to chain on mirror functions to further manipulate your query before sending it to Imengine.
with
Add or override parameters not specific to the function being used
Parameters:
Parameter | Type | Description |
| array | Optional. Parameters to send forth to the Imengine url. |
quality
Allow for quality change of the requested image
Parameters:
Parameter | Type | Description |
| int | The quality in percent (1-100) for the resulted image. |
format
Set the format of the requested image. Imengine will default to jpg
Parameters:
Parameter | Type | Description | |
| string | The format of the resulted image (jpg | png). (default='jpg') |
Last updated