SilverStripe\Assets\InterventionBackend
Synopsis
class InterventionBackend
implements
Image_Backend,Flushable
{
- // constants
- const CACHE_MARK = 'MARK_';
- const CACHE_DIMENSIONS = 'DIMENSIONS_';
- const FAILED_INVALID = 'invalid';
- const FAILED_MISSING = 'missing';
- const FAILED_UNKNOWN = 'unknown';
- // members
- private static boolean $flush_enabled = true;
- private static array $error_cache_ttl = ;
- private static string $local_temp_path = TEMP_PATH;
- private AssetContainer $container;
- private Image $image;
- private $quality;
- private ImageManager $manager;
- private CacheInterface $cache;
- private $tempPath;
- // methods
- public void __construct()
- public string getTempPath()
- public $this setTempPath()
- public CacheInterface getCache()
- public $this setCache()
- public AssetContainer getAssetContainer()
- public $this setAssetContainer()
- public ImageManager getImageManager()
- public $this setImageManager()
- public $this loadFromContainer()
- public Image getImageResource()
- public $this loadFrom()
- public $this setImageResource()
- public array writeToStore()
- public bool writeTo()
- public int getQuality()
- protected array getDimensions()
- protected array getResourceDimensions()
- protected string getErrorCacheKey()
- protected string getDimensionCacheKey()
- protected void warmCache()
- public int getWidth()
- public int getHeight()
- public $this setQuality()
- public InterventionBackend resize()
- public InterventionBackend resizeRatio()
- public InterventionBackend resizeByWidth()
- public InterventionBackend resizeByHeight()
- public InterventionBackend paddedResize()
- public InterventionBackend croppedResize()
- public Image_Backend crop()
- protected InterventionBackend createCloneWithResource()
- protected void markSuccess()
- protected void markFailed()
- protected string|null hasFailed()
- public void __destruct()
- public static void flush()
- protected bool isStreamReadable()
Hierarchy
Uses
- SilverStripe\Core\Config\Configurable
Implements
- SilverStripe\Assets\Image_Backend
- SilverStripe\Core\Flushable
Constants
Name | Value |
---|---|
CACHE_MARK | 'MARK_' |
CACHE_DIMENSIONS | 'DIMENSIONS_' |
FAILED_INVALID | 'invalid' |
FAILED_MISSING | 'missing' |
FAILED_UNKNOWN | 'unknown' |
ORIENTATION_SQUARE | 0 |
ORIENTATION_PORTRAIT | 1 |
ORIENTATION_LANDSCAPE | 2 |
Members
private
- $cache — Psr\SimpleCache\CacheInterface
- $container — SilverStripe\Assets\Storage\AssetContainer
- $error_cache_ttl
—
array
How long to cache each error type - $flush_enabled
—
boolean
Is cache flushing enabled? - $image — Intervention\Image\Image
- $local_temp_path
—
string
Configure where cached intervention files will be stored - $manager — Intervention\Image\ImageManager
- $quality — int
- $tempPath — string
Methods
protected
- createCloneWithResource() — Modify this image backend with either a provided resource, or transformation
- getDimensionCacheKey() — Cache key for dimensions for given container
- getDimensions() — Return dimensions as array with cache enabled
- getErrorCacheKey() — Cache key for recording errors
- getResourceDimensions() — Get dimensions from the given resource
- hasFailed() — Determine reason this file could not be loaded.
- isStreamReadable() — Validate the stream resource is readable
- markFailed() — Mark this image as failed to load
- markSuccess() — Clear any cached errors / metadata for this image
- warmCache() — Warm dimension cache for the given asset
public
- __construct()
- __destruct() — Make sure we clean up the image resource when this object is destroyed
- crop() — Crop's part of image.
- croppedResize() — Resize an image to cover the given width/height completely, and crop off any overhanging edges.
- 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.
- getAssetContainer()
- getCache()
- getHeight()
- getImageManager()
- getImageResource() — Get the currently assigned image resource, or generates one if not yet assigned.
- getQuality()
- getTempPath()
- getWidth()
- loadFrom() — Populate the backend from a local path
- loadFromContainer() — Populate the backend with a given object
- paddedResize() — Return a clone of this image resized, with space filled in with the given colour
- resize() — Resize an image, skewing it as necessary.
- resizeByHeight() — Resize an image by height. Preserves aspect ratio.
- resizeByWidth() — Resize an image by width. Preserves aspect ratio.
- resizeRatio() — 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
- setAssetContainer()
- setCache()
- setImageManager()
- setImageResource()
- setQuality() — Set the quality to a value between 0 and 100
- setTempPath()
- writeTo() — Write the backend to a local path
- writeToStore() — Write to the given asset store