ImageTransforms ​
- Type
- Class
- Namespace
- craft\helpers
- Inherits
- craft\helpers\ImageTransforms
- Since
- 4.0.0
Image Transforms helper.
Public Methods ​
Method | Description |
---|---|
createTransformFromString() | Create an AssetImageTransform model from a string. |
detectTransformFormat() | Detect the auto web-safe format for the Asset. Returns null, if the Asset is not an image. |
extendTransform() | Extend a transform by taking an existing transform and overriding its parameters. |
generateTransform() | Generates an image transform for an asset. |
getLocalImageSource() | Get a local image source to use for transforms. |
getTransformString() | Get the transform string for a given asset image transform. |
normalizeTransform() | Normalize a transform from handle or a set of properties to an ImageTransform. |
parseTransformString() | Parses a transform string. |
storeLocalSource() | Store a local image copy to a destination path. |
createTransformFromString()
​
Create an AssetImageTransform model from a string.
Arguments ​
$transformString
(string)
Returns ​
detectTransformFormat()
​
Detect the auto web-safe format for the Asset. Returns null, if the Asset is not an image.
Arguments ​
$asset
(craft\elements\Asset)
Returns ​
Throws ​
- craft\errors\AssetOperationException
If attempting to detect an image format for a non-image.
extendTransform()
​
Extend a transform by taking an existing transform and overriding its parameters.
Arguments ​
$transform
(craft\models\ImageTransform)$parameters
(array)
Returns ​
generateTransform()
​
Generates an image transform for an asset.
Arguments ​
$asset
(craft\elements\Asset) – The asset$transform
(craft\models\ImageTransform) – The image transform$heartbeat
(callable, null) – A callback that should be called while the transform is being generated$image
(craft\base\Image, null) – The image object loaded for the transform
Returns ​
string – The temp path that the transform was saved to
Throws ​
- craft\errors\ImageTransformException
if the transform couldn’t be generated.
getLocalImageSource()
​
Get a local image source to use for transforms.
Arguments ​
$asset
(craft\elements\Asset)
Returns ​
Throws ​
- craft\errors\FsObjectNotFoundException
If the file cannot be found.
getTransformString()
​
Get the transform string for a given asset image transform.
Arguments ​
$transform
(craft\models\ImageTransform)$ignoreHandle
(boolean) – Whether the transform handle should be ignored
Returns ​
normalizeTransform()
​
Normalize a transform from handle or a set of properties to an ImageTransform.
Arguments ​
$transform
(mixed
)
Returns ​
craft\models\ImageTransform, null
Throws ​
- craft\errors\ImageTransformException
if $transform is an invalid transform handle
parseTransformString()
​
- Since
- 4.4.0
Parses a transform string.
Arguments ​
$str
(string)
Returns ​
storeLocalSource()
​
Store a local image copy to a destination path.
Arguments ​
Throws ​
Constants ​
Constant | Description |
---|---|
TRANSFORM_STRING_PATTERN |