interface ThumbnailerInterface (View source)

Interface ThumbnailerInterface An interface for classes tasked with creating thumbnails. This interace requires imagine.

Methods

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(ImagineInterface|string $image, string $savePath, int|null $width, int|null $height, bool $fit = false)

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

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.

Details

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.

Parameters

StorageLocationInterface $storageLocation

Return Value

ThumbnailerInterface

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

int getJpegCompression()

Get the currently set JPEG compression level.

Return Value

int

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

int getPngCompression()

Get the currently set PNG compression level.

Return Value

int

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

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

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

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

Parameters

ImagineInterface|string $image

the image for which you want the thumbnail (or its path)

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?

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)