InterventionBackend
class InterventionBackend implements Image_Backend, Flushable (View source)
Traits
Provides extensions to this object to integrate it with standard config API methods.
Constants
CACHE_MARK |
Cache prefix for marking |
CACHE_DIMENSIONS |
Cache prefix for dimensions |
FAILED_INVALID |
This file is invalid because it is not image data, or it cannot
be processed by the given backend |
FAILED_MISSING |
This file is invalid as it is missing from the filesystem |
FAILED_UNKNOWN |
Some unknown error |
Config options
flush_enabled | bool | Is cache flushing enabled? |
|
error_cache_ttl | array | How long to cache each error type |
|
local_temp_path | string | Configure where cached intervention files will be stored |
Properties
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
Get the currently assigned image resource, or generates one if not yet assigned.
Write to the given asset store
Cache key for recording errors
Cache key for dimensions for given container
Warm dimension cache for the given asset
Resize the image by preserving aspect ratio. By default, it will keep the image inside the maxWidth and maxHeight. Passing useAsMinimum will make the smaller dimension equal to the maximum corresponding dimension
Return a clone of this image resized, with space filled in with the given colour
Resize an image to cover the given width/height completely, and crop off any overhanging edges.
Modify this image backend with either a provided resource, or transformation
Clear any cached errors / metadata for this image
Mark this image as failed to load
Determine reason this file could not be loaded.
This function is triggered early in the request if the "flush" query parameter has been set. Each class that implements Flushable implements this function which looks after it's own specific flushing functionality.
Details
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
__construct(AssetContainer $assetContainer = null)
Create a new backend with the given object
string
getTempPath()
No description
$this
setTempPath(string $path)
No description
CacheInterface
getCache()
No description
$this
setCache(CacheInterface $cache)
No description
AssetContainer
getAssetContainer()
No description
$this
setAssetContainer(AssetContainer $assetContainer)
No description
ImageManager
getImageManager()
No description
$this
setImageManager(ImageManager $manager)
No description
loadFromContainer(AssetContainer $assetContainer)
Populate the backend with a given object
mixed
getImageResource()
Get the currently assigned image resource, or generates one if not yet assigned.
Note: This method may return null if error
loadFrom(string $path)
Populate the backend from a local path
setImageResource(Image $image)
No description
array
writeToStore(AssetStore $assetStore, string $filename, string $hash = null, string $variant = null, array $config = [])
Write to the given asset store
bool
writeTo(string $path)
Write the backend to a local path
int
getQuality()
No description
protected array
getDimensions()
Return dimensions as array with cache enabled
protected array
getResourceDimensions(Image $resource)
Get dimensions from the given resource
protected string
getErrorCacheKey(string $hash, string|null $variant = null)
Cache key for recording errors
protected string
getDimensionCacheKey(string $hash, string|null $variant = null)
Cache key for dimensions for given container
protected
warmCache(string $hash, string|null $variant = null)
Warm dimension cache for the given asset
int
getWidth()
No description
int
getHeight()
No description
setQuality(int $quality)
Set the quality to a value between 0 and 100
Image_Backend
resize(int $width, int $height)
Resize an image, skewing it as necessary.
Image_Backend
resizeRatio(int $width, int $height, bool $useAsMinimum = false)
Resize the image by preserving aspect ratio. By default, it will keep the image inside the maxWidth and maxHeight. Passing useAsMinimum will make the smaller dimension equal to the maximum corresponding dimension
Image_Backend
resizeByWidth(int $width)
Resize an image by width. Preserves aspect ratio.
Image_Backend
resizeByHeight(int $height)
Resize an image by height. Preserves aspect ratio.
Image_Backend
paddedResize(int $width, int $height, string $backgroundColor = "FFFFFF", int $transparencyPercent = 0)
Return a clone of this image resized, with space filled in with the given colour
Image_Backend
croppedResize(int $width, int $height)
Resize an image to cover the given width/height completely, and crop off any overhanging edges.
Image_Backend
crop(int $top, int $left, int $width, int $height)
Crop's part of image.
protected InterventionBackend
createCloneWithResource(Image|callable $resourceOrTransformation)
Modify this image backend with either a provided resource, or transformation
protected
markSuccess(string $hash, string|null $variant = null)
Clear any cached errors / metadata for this image
protected
markFailed(string $hash, string|null $variant = null, string $reason = InterventionBackend::FAILED_UNKNOWN)
Mark this image as failed to load
protected string|null
hasFailed(string $hash, string|null $variant = null)
Determine reason this file could not be loaded.
Will return one of the FAILED_* constant values, or null if not failed
__destruct()
Make sure we clean up the image resource when this object is destroyed
static
flush()
This function is triggered early in the request if the "flush" query parameter has been set. Each class that implements Flushable implements this function which looks after it's own specific flushing functionality.
protected bool
isStreamReadable(mixed $stream)
Validate the stream resource is readable