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
Create a new backend with the given object
Get the currently assigned image resource, or generates one if not yet assigned.
No description
Get dimensions from the given resource
Cache key for recording errors
Cache key for dimensions for given container
Warm dimension cache for the given asset
No description
No description
No description
No description
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|null $assetContainer = null)
Create a new backend with the given object
string|null
getTempPath()
Get the temporary local path for this image
InterventionBackend
setTempPath(string $path)
Set the temporary local path for this image
CacheInterface
getCache()
No description
InterventionBackend
setCache(CacheInterface $cache)
No description
AssetContainer|null
getAssetContainer()
No description
InterventionBackend
setAssetContainer(AssetContainer|null $assetContainer)
No description
ImageManager
getImageManager()
No description
InterventionBackend
setImageManager(ImageManager $manager)
No description
Image_Backend
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
Image_Backend
loadFrom(string $path)
Populate the backend from a local path
Image_Backend
setImageResource(ImageInterface $image)
No description
array
writeToStore(AssetStore $assetStore, string $filename, string|null $hash = null, string|null $variant = null, array $config = [])
No description
bool
writeTo(string $path)
No description
int
getQuality()
No description
protected array
getDimensions()
Return dimensions as array with cache enabled
Returns a two-length array with width and height
protected array
getResourceDimensions(ImageInterface $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 void
warmCache(string $hash, string|null $variant = null)
Warm dimension cache for the given asset
int
getWidth()
No description
int
getHeight()
No description
Image_Backend
setQuality(int $quality)
No description
Image_Backend|null
resize(int $width, int $height)
No description
Image_Backend|null
resizeRatio(int $width, int $height, bool $useAsMinimum = false)
No description
Image_Backend|null
resizeByWidth(int $width)
No description
Image_Backend|null
resizeByHeight(int $height)
No description
Image_Backend|null
paddedResize(string $width, string $height, string $backgroundColour = 'FFFFFF', int $transparencyPercent = 0)
No description
Image_Backend|null
croppedResize(int $width, int $height, string $position = 'center')
No description
Image_Backend|null
crop(int $top, int $left, int $width, int $height, string $position = 'top-left', string $backgroundColour = 'FFFFFF')
No description
Image_Backend
setAllowsAnimationInManipulations(bool $allow)
No description
bool
getAllowsAnimationInManipulations()
No description
bool
getIsAnimated()
No description
Image_Backend|null
removeAnimation(int|string $position)
No description
protected InterventionBackend|null
createCloneWithResource(ImageInterface|callable $resourceOrTransformation)
Modify this image backend with either a provided resource, or transformation
protected void
markSuccess(string $hash, string|null $variant = null)
Clear any cached errors / metadata for this image
protected void
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