class BasicThumbnailer implements ThumbnailerInterface, ApplicationAwareInterface (View source)

Traits

Trait ApplicationAwareTrait A trait used with ApplicationAwareInterface

Properties

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

The currently configured JPEG compression level.

protected int|null $pngCompression

The currently configured PNG compression level.

protected string|null $thumbnailsFormat

The currently configured format of the generated thumbnails.

private StorageLocationInterface $storageLocation

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).

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

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

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

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

processThumbnail(bool $async, File|string $obj, int|null $maxWidth, int|null $maxHeight, bool $crop)

No description

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

one of the \Concrete\Core\File\Image\BitmapFormat::FORMAT_ constants, or \Concrete\Core\File\Image\Thumbnail\ThumbnailFormatService::FORMAT_AUTO

Return Value

ThumbnailerInterface

See also

ThumbnailerInterface::setThumbnailsFormat

string getThumbnailsFormat()

Get the format of the generated thumbnails.

Return Value

string

one of the \Concrete\Core\File\Image\BitmapFormat::FORMAT_ constants, or \Concrete\Core\File\Image\Thumbnail\ThumbnailFormatService::FORMAT_AUTO

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 returnThumbnailObjectFromResolver(File|string $obj, int|null $maxWidth, int|null $maxHeight, bool $crop = false)

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

Parameters

File|string $obj

file instance of path to a file

int|null $maxWidth
int|null $maxHeight
bool $crop

Return Value

stdClass

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

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

File|string $obj

file instance of path to a file

int|null $maxWidth
int|null $maxHeight
bool $crop

Return Value

stdClass

stdClass processThumbnail(bool $async, File|string $obj, int|null $maxWidth, int|null $maxHeight, bool $crop)

No description

Parameters

bool $async
File|string $obj
int|null $maxWidth
int|null $maxHeight
bool $crop

Return Value

stdClass

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