final class ImageHelper extends BasicThumbnailer (View source)

deprecated

This is deprecated. It will be removed. Use Core::make('image/thumbnailer') to grab the current class instead.

Traits

Trait ApplicationAwareTrait A trait used with ApplicationAwareInterface

Properties

protected Application $app from  ApplicationAwareTrait
protected int|null $jpegCompression

The currently configured JPEG compression level.

from  BasicThumbnailer
protected int|null $pngCompression

The currently configured PNG compression level.

from  BasicThumbnailer
protected string|null $thumbnailsFormat

The currently configured format of the generated thumbnails.

from  BasicThumbnailer
private StorageLocationInterface $storageLocation from  BasicThumbnailer

Methods

setApplication(Application $app)

Setter method for the application

__construct(StorageLocationInterface $storageLocation = null)

No description

getStorageLocation()

Get the storage location to use.

setStorageLocation(StorageLocationInterface $storageLocation)

Set the storage location to use. Note that the $savePath is going to be relative to this location.

setJpegCompression(int $level)

Overrides the default JPEG compression level per instance of the image helper.

int
getJpegCompression()

Get the currently set JPEG compression level.

setPngCompression(int $level)

Overrides the default PNG compression level per instance of the image helper.

int
getPngCompression()

Get the currently set PNG compression level.

setThumbnailsFormat(string $thumbnailsFormat)

Set the format of the generated thumbnails.

string
getThumbnailsFormat()

Get the format of the generated thumbnails.

create($mixed, string $savePath, int|null $width, int|null $height, bool $fit = false, $format = false)

Create a thumbnail given an image (or a path to an image).

checkForThumbnailAndCreateIfNecessary($obj, $maxWidth, $maxHeight, bool $crop = false) deprecated

Checks filesystem for thumbnail and if file doesn't exist will create it immediately.

returnThumbnailObjectFromResolver($obj, $maxWidth, $maxHeight, bool $crop = false)

Checks thumbnail resolver for filename, schedule for creation via ajax if necessary.

stdClass
getThumbnail(File|string $obj, int|null $maxWidth, int|null $maxHeight, bool $crop = false)

Returns a path to the specified item, resized and/or cropped to meet max width and height. $obj can e Returns an object with the following properties: src, width, height.

outputThumbnail($mixed, $maxWidth, $maxHeight, $alt = null, $return = false, $crop = false) deprecated

No description

Details

setApplication(Application $app)

Setter method for the application

Parameters

Application $app

__construct(StorageLocationInterface $storageLocation = null)

No description

Parameters

StorageLocationInterface $storageLocation

StorageLocationInterface getStorageLocation()

Get the storage location to use.

ThumbnailerInterface setStorageLocation(StorageLocationInterface $storageLocation)

Set the storage location to use. Note that the $savePath is going to be relative to this location.

ThumbnailerInterface setJpegCompression(int $level)

Overrides the default JPEG compression level per instance of the image helper.

This allows for a single-use for a particularly low or high compression value.

Parameters

int $level

the level of compression (in the range 0...100)

Return Value

ThumbnailerInterface

See also

ThumbnailerInterface::setJpegCompression

int getJpegCompression()

Get the currently set JPEG compression level.

ThumbnailerInterface setPngCompression(int $level)

Overrides the default PNG compression level per instance of the image helper.

This allows for a single-use for a particularly low or high compression value.

Parameters

int $level

the level of compression (in the range 0...9)

Return Value

ThumbnailerInterface

See also

ThumbnailerInterface::setPngCompression

int getPngCompression()

Get the currently set PNG compression level.

Return Value

int

See also

ThumbnailerInterface::getPngCompression

ThumbnailerInterface setThumbnailsFormat(string $thumbnailsFormat)

Set the format of the generated thumbnails.

Parameters

string $thumbnailsFormat

valid values: 'auto', 'jpeg', 'png'

Return Value

ThumbnailerInterface

See also

ThumbnailerInterface::setThumbnailsFormat

string getThumbnailsFormat()

Get the format of the generated thumbnails.

Return Value

string

one of 'auto', 'jpeg', 'png'

See also

ThumbnailerInterface::getThumbnailsFormat

create($mixed, string $savePath, int|null $width, int|null $height, bool $fit = false, $format = false)

Create a thumbnail given an image (or a path to an image).

Parameters

$mixed
string $savePath

The path to save the thumbnail to

int|null $width

The thumbnail width (may be empty if $fit is false and $height is specified)

int|null $height

The thumbnail height (may be empty if $fit is false and $width is specified)

bool $fit

Fit to bounds?

$format

See also

ThumbnailerInterface::create

private stdClass checkForThumbnailAndCreateIfNecessary($obj, $maxWidth, $maxHeight, bool $crop = false) deprecated

deprecated

Checks filesystem for thumbnail and if file doesn't exist will create it immediately.

concrete5's default behavior from the beginning up to 8.1.

Parameters

$obj
$maxWidth
$maxHeight
bool $crop

Return Value

stdClass

private returnThumbnailObjectFromResolver($obj, $maxWidth, $maxHeight, bool $crop = false)

Checks thumbnail resolver for filename, schedule for creation via ajax if necessary.

Parameters

$obj
$maxWidth
$maxHeight
bool $crop

stdClass getThumbnail(File|string $obj, int|null $maxWidth, int|null $maxHeight, bool $crop = false)

Returns a path to the specified item, resized and/or cropped to meet max width and height. $obj can e Returns an object with the following properties: src, width, height.

Parameters

File|string $obj

a string (path) or a file object

int|null $maxWidth

The maximum width of the thumbnail (may be empty if $crop is false and $maxHeight is specified)

int|null $maxHeight

The maximum height of the thumbnail (may be empty if $crop is false and $maxWidth is specified)

bool $crop

Fit to bounds?

Return Value

stdClass

Object that has the following properties: src (the public URL to the file), width (null if unable to determine it), height (null if unable to determine it)

See also

ThumbnailerInterface::getThumbnail

outputThumbnail($mixed, $maxWidth, $maxHeight, $alt = null, $return = false, $crop = false) deprecated

deprecated

No description

Parameters

$mixed
$maxWidth
$maxHeight
$alt
$return
$crop