Naviga Web
Docs Home
  • Introduction
  • Release notes
  • Starter kit
    • Introduction
    • Environment Variables
    • Makefile
    • Changelog
    • API
  • Feature: Advanced Search
    • User guide
    • Search Help
    • How to Setup
    • Technical Details
  • Developer documentation
    • Developer prerequisites
      • Developer hardware suggestions
      • Setup on Windows
      • Setup on Linux/Ubuntu
    • Getting started with development
      • Composer package management
      • Gulp and asset building (optional)
      • Git
      • Hosts file
      • Certificate
      • Initiate Naviga Web
      • Start Naviga Web
      • Bin scripts
      • Create theme
      • Environments
      • Deployment
      • Onboarding tasks
        • #0 - New site
        • #1 - Configuration
        • #2 - Front page
        • #3 - Content presentation
        • #4 - OC List
        • #5 - Content containers
        • #6 - Teaser template
        • #7 - Single article
        • #8 - Widget
        • #9 - Custom task
        • #10 - Feedback
    • Architecture
    • Paywall and authentication
      • CloudFront Paywall
      • Engage paywall
      • Lua Paywall (deprecated)
    • Project management: A typical project
    • Database dump
    • Debugging
    • Keep your project up-to-date
    • Gulp and Sass
    • Domain mapping
    • Widgets overview
  • Starter kit packages
    • Base package
      • Changelog
    • Boards plugin (EveryBoard)
      • Installation
      • Setup
      • Board Widgets
        • Linked board
        • Template board
        • Embed widget
        • OC List item
        • Content container
      • Teaser templates
      • Actions and filters
      • Export - import
      • Changelog
    • ContentSync plugin
      • Usage
      • Changelog
    • Drop In Plugins package
      • Changelog
    • Everyware plugin
      • Installation
      • Setup
      • Actions and filters
      • Fetching lists and their content
      • Sorting
      • Widgets
      • Changelog
    • Imengine package
      • Helper class: Imengine
      • Changelog
    • NewsML package
      • Idf Parser
      • Changelog
      • Usage
    • NGINX conf package
      • API
      • Changelog
      • Usage
    • Presentation Preview plugin
      • API
      • Changelog
      • Usage
    • Support package
      • Changelog
    • Theme EU resources package*
      • Changelog
    • Theme US resources package
      • Changelog
    • Twig package
      • Development
        • Filters
          • class_string
          • spacey
          • trim_array
        • Functions
          • php_function
          • php_method
          • render_classes
          • render_partial
        • Operators
          • contains
      • Helper classes
        • View
        • ViewSetup
      • Changelog
  • Widgets and component packages
    • Article List widget
      • Installation
      • Using Article List
      • Changelog
    • Menu handler
      • Usage
      • Changelog
    • Section Header widget
      • Changelog
    • Social media icons widget
      • Installation
      • Changelog
    • Google Analytics plugin
      • Set up Google Analytics
      • Most read widget
      • Changelog
    • Redirect Original URLs plugin
      • Installation
      • Changelog
    • Settings Parameters plugin
      • Installation
      • Usage
      • Changelog
  • Design and theme packages
    • Base theme 1
      • Changelog
    • Base theme 2
      • Colors
      • Fonts
      • Header
      • Menus
      • Pages with Board
      • Sidebars
      • Teaser layouts
      • Article page (text)
      • Article page (embeds)
      • Changelog
    • Example theme
      • Changelog
  • MU Plugins
    • Project Plugin
      • Installation
      • Changelog
    • Starter Package Catalyst
    • Concepts
      • Admin Pages
        • All Concepts
        • Add New Concept
        • Types
        • Errors
        • Concept duplicates
      • API
      • Console
      • Changelog
    • Network
      • Changelog
    • Cache Invalidator
      • Getting Started & WP admin
      • Implementation of Lua endpoint
      • Filters
      • Changelog
    • RSS Feeds
      • Setup
      • Administration pages
      • Changelog
  • Services
    • Imengine
    • Imengine documentation
    • Open Content
    • Writer Bookmarklet
Powered by GitBook
On this page
  • Setup and configuration
  • Setup and configuration from Base theme
  • Standard usage
  • Required methods:
  • Static functions
  • create
  • createMirrorFunction
  • Mirrored functions
  • cover
  • cropResize
  • fit
  • hardcrop
  • newsPilotCrop
  • original
  • thumbnail
  • ratio
  • autoCrop
  • square
  • raw
  • Chainable functions
  • with
  • quality
  • format

Was this helpful?

  1. Starter kit packages
  2. Imengine package

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:

Imengine::setup(string $serverUrl): void;

Parameters:

Parameter

Type

Description

$serverUrl

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:

CF_IMENGINE=https://imengine.public.infomaker.io

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

Imengine::fromUuid(string $uuid): string;

Parameters:

Parameter

Type

Description

$uuid

string

The uuid of the image in Open Content.

fromSrc

Defines what src that Imengine will manipulate

Imengine::fromSrc(string $imgSrc): string;

Parameters:

Parameter

Type

Description

$imgSrc

string

The url to an external image.

Example:

$imageSrc = Imengine::original()->fromUuid($uuid);

//or

$imageSrc = Imengine::original()->fromSrc($imgSrc);

Static functions

create

Create url from scratch by using parameters provided

Imengine::create(array $params = null): $this

Parameters:

Parameter

Type

Description

$params

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.

Imengine::createMirrorFunction(string $func, array $params = null): $this

Parameters:

Parameter

Type

Description

$func

string

The Imengine server-function to use

$params

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.

Imengine::cover(int $width = null, int $height = null): $this

Parameters:

Parameter

Type

Description

$width

int

Optional. limits the width to amount in pixels (default=null)

$height

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.

Imengine::cropResize(CropResizeDataInterface $cropData): $this

Uses: \Infomaker\Imengine\CropData\Interfaces\CropResizeDataInterface

Parameters:

Parameter

Type

Description

$cropData

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)

Imengine::fit(int $maxSize, bool $scaleUp = true): $this

Parameters:

Parameter

Type

Description

$maxsize

int

The limits to for height and width

$scaleUp

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

Imengine::hardCrop(int $width, int $height): $this

Parameters:

Parameter

Type

Description

$width

int

Resulted width

$height

int

Resulted height

newsPilotCrop

Crop image into defined size from custom start-positions. Implemented as crop for NewsPilot

Imengine::newsPilotCrop(NewsPilotCropDataInterface $cropData): $this

Uses: \Infomaker\Imengine\CropData\Interfaces\NewsPilotCropDataInterface

Parameters:

Parameter

Type

Description

$cropData

NewsPilotCropDataInterface

An interface from where the necessary data can be extracted.

original

Fetch image with original size.

Imengine::original(): $this

Parameters: No parameters

thumbnail

Crop image into defined size from center position

Imengine::thumbnail(int $width, int $height): $this

Parameters:

Parameter

Type

Description

$width

int

Resulted width

$height

int

Resulted height

ratio

Crop image into given ratio using "hardcrop".

Imengine::ratio(int $width, string $ratio = null): $this

Parameter

Type

Description

$width

int

Resulted width

$ratio

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"

Imengine::autoCrop(AutoCropDataInterface $cropData): $this

Uses: \Infomaker\Imengine\CropData\Interfaces\AutoCropDataInterface

Parameters:

Parameter

Type

Description

$cropData

AutoCropDataInterface

An interface from where the necessary data can be extracted.

square

Crop image into a square using "hardcrop".

Imengine::square(int $size): $this

Parameters:

Parameter

Type

Description

$size

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.

Imengine::raw(string $uuid, int $quality = null): string

Parameters:

Parameter

Type

Description

$uuid

string

The uuid of the

$quality

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

Imengine::with(array $params): string;

Parameters:

Parameter

Type

Description

$params

array

Optional. Parameters to send forth to the Imengine url.

quality

Allow for quality change of the requested image

Imengine::quality(int $quality): $this;

Parameters:

Parameter

Type

Description

$quality

int

The quality in percent (1-100) for the resulted image.

format

Set the format of the requested image. Imengine will default to jpg

Imengine::format(string $format): $this;

Parameters:

Parameter

Type

Description

$format

string

The format of the resulted image (jpg

png). (default='jpg')

PreviousImengine packageNextChangelog

Last updated 5 years ago

Was this helpful?

create
createMirrorFunction
cover
cropResize
fit
hardcrop
newsPilotCrop
original
thumbnail
ratio
autoCrop
square
with
quality
format