AssetTransformsService

Type
Class
Namespace
Craft
Inherits
Craft\AssetTransformsService » Craft\BaseApplicationComponent » CApplicationComponent (opens new window) » CComponent (opens new window)
Implements
IApplicationComponent
Since
1.0
Deprecated in
This class will have several breaking changes in Craft 3.0.

Class AssetTransformsService

See also http://craftcms.com

View source (opens new window)

# Public Properties

Property Description
$behaviors (opens new window) array (opens new window) – The behaviors that should be attached to this component.

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__get() (opens new window) Returns a property value, an event handler list or a behavior based on its name.
__isset() (opens new window) Checks if a property value is null.
__set() (opens new window) Sets value of a component property.
__unset() (opens new window) Sets a component property to be null.
asa() (opens new window) Returns the named behavior object.
attachBehavior() (opens new window) Attaches a behavior to this component.
attachBehaviors() (opens new window) Attaches a list of behaviors to the component.
attachEventHandler() (opens new window) Attaches an event handler to an event.
canGetProperty() (opens new window) Determines whether a property can be read.
canSetProperty() (opens new window) Determines whether a property can be set.
deleteAllTransformData() Delete ALL transform data (including thumbs and sources) associated with file.
deleteCreatedTransformsForFile() Delete created transforms for a file.
deleteQueuedSourceFiles() Delete all image sources queued up for deletion.
deleteThumbnailsForFile() Delete all the generated thumbnails for the file.
deleteTransform() Deletes an asset transform by it's id.
deleteTransformIndex() Delete a transform index by.
deleteTransformIndexDataByFileId() Delete transform records by a file id.
detachBehavior() (opens new window) Detaches a behavior from the component.
detachBehaviors() (opens new window) Detaches all behaviors from the component.
detachEventHandler() (opens new window) Detaches an existing event handler.
detectAutoTransformFormat() Detect the auto web-safe format for the Assets file. Returns null, if the file is not an image.
disableBehavior() (opens new window) Disables an attached behavior.
disableBehaviors() (opens new window) Disables all behaviors attached to this component.
eagerLoadTransforms() Eager-loads transform indexes for a given set of file IDs.
enableBehavior() (opens new window) Enables an attached behavior.
enableBehaviors() (opens new window) Enables all behaviors attached to this component.
ensureTransformUrlByIndexModel() Get a transform URL by the transform index model.
evaluateExpression() (opens new window) Evaluates a PHP expression or callback under the context of this component.
generateTransform() Generate a transform by a created index.
getActiveTransformIndexModel()
getAllCreatedTransformsForFile() Get an array of AssetIndexDataModel for all created transforms for a file.
getAllTransforms() Returns all named asset transforms.
getCachedCloudImageSize() Get the size of max cached cloud images dimension.
getEventHandlers() (opens new window) Returns the list of attached event handlers for an event.
getIsInitialized() (opens new window) Checks if this application component has been initialized.
getLocalImageSource() Get a local image source to use for transforms.
getPendingTransformIndexIds() Returns a list of pending transform index IDs.
getThumbServerPath() Get a thumb server path by file model and size.
getTransformByHandle() Returns an asset transform by its handle.
getTransformFilename() Return the filename used by the Transform Index for the File.
getTransformIndex() Get a transform index row. If it doesn't exist - create one.
getTransformIndexModelByFileIdAndHandle() Get a transform index model by a row id.
getTransformIndexModelById() Get a transform index model by a row id.
getTransformSubfolder() Return a subfolder used by the Transform Index for the File.
getTransformSubpath() Get a transform subpath used by the Transform Index for the File.
getUrlForTransformByAssetAndTransformIndex() Get the URL for transform for the given asset, by the given transform index model
getUrlForTransformByIndexId() Get URL for Transform by TransformIndexId.
getUrlForTransformByTransformIndex() Get URL for Transform by the transform index model.
hasEvent() (opens new window) Determines whether an event is defined.
hasEventHandler() (opens new window) Checks whether the named event has attached handlers.
hasProperty() (opens new window) Determines whether a property is defined.
init() (opens new window) Initializes the application component.
isInitialized() Checks if this application component has been initialized yet, or not.
normalizeTransform() Normalize a transform from handle or a set of properties to an AssetTransformModel.
queueSourceForDeletingIfNecessary() Deletes an image local source if required by config.
raiseEvent() (opens new window) Raises an event.
saveTransform() Saves an asset transform.
setActiveTransformIndexModel()
storeLocalSource() Store a local image copy to a destination path.
storeTransformIndexData() Store a transform index data by it's model.
validateTransformIndexResult() Validates a transform index result to see if the index is still valid for a given file.

# deleteAllTransformData()

Delete ALL transform data (including thumbs and sources) associated with file.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null deleteAllTransformData ( Craft\AssetFileModel $file )

# deleteCreatedTransformsForFile()

Delete created transforms for a file.

View source (opens new window)

Arguments

Signature

public void deleteCreatedTransformsForFile ( Craft\AssetFileModel $file )

# deleteQueuedSourceFiles()

Delete all image sources queued up for deletion.

View source (opens new window)

Returns

null (opens new window)

Signature

public null deleteQueuedSourceFiles ( )

# deleteThumbnailsForFile()

Delete all the generated thumbnails for the file.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null deleteThumbnailsForFile ( Craft\AssetFileModel $file )

# deleteTransform()

Deletes an asset transform by it's id.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Throws

Signature

public boolean deleteTransform ( $transformId )

# deleteTransformIndex()

Delete a transform index by.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null deleteTransformIndex ( $indexId )

# deleteTransformIndexDataByFileId()

Delete transform records by a file id.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null deleteTransformIndexDataByFileId ( $fileId )

# detectAutoTransformFormat()

Detect the auto web-safe format for the Assets file. Returns null, if the file is not an image.

View source (opens new window)

Arguments

Returns

mixed, string (opens new window)

Throws

Signature

public mixed, string detectAutoTransformFormat ( Craft\AssetFileModel $file )

# eagerLoadTransforms()

Eager-loads transform indexes for a given set of file IDs.

View source (opens new window)

Arguments

Returns

void

Signature

public void eagerLoadTransforms ( $files, $transforms )

# ensureTransformUrlByIndexModel()

Get a transform URL by the transform index model.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

Signature

public string ensureTransformUrlByIndexModel ( Craft\AssetTransformIndexModel $index )

# generateTransform()

Generate a transform by a created index.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null generateTransform ( Craft\AssetTransformIndexModel $index )

# getActiveTransformIndexModel()

Signature

public mixed getActiveTransformIndexModel ( )

# getAllCreatedTransformsForFile()

Get an array of AssetIndexDataModel for all created transforms for a file.

View source (opens new window)

Arguments

Returns

array (opens new window)

Signature

public array getAllCreatedTransformsForFile ( Craft\AssetFileModel $file )

# getAllTransforms()

Returns all named asset transforms.

View source (opens new window)

Arguments

Returns

array (opens new window)

Signature

public array getAllTransforms ( $indexBy = null )

# getCachedCloudImageSize()

Get the size of max cached cloud images dimension.

View source (opens new window)

Returns

integer (opens new window)

Signature

public integer getCachedCloudImageSize ( )

# getLocalImageSource()

Get a local image source to use for transforms.

View source (opens new window)

Arguments

  • $file

Returns

mixed

Throws

Signature

public mixed getLocalImageSource ( Craft\AssetFileModel $file )

# getPendingTransformIndexIds()

Returns a list of pending transform index IDs.

View source (opens new window)

Returns

array (opens new window)

Signature

public array getPendingTransformIndexIds ( )

# getThumbServerPath()

Get a thumb server path by file model and size.

View source (opens new window)

Arguments

  • $fileModel
  • $size

Returns

boolean (opens new window), string (opens new window)

Throws

Signature

public boolean, string getThumbServerPath ( Craft\AssetFileModel $fileModel, $size )

# getTransformByHandle()

Returns an asset transform by its handle.

View source (opens new window)

Arguments

Returns

Craft\AssetTransformModel, null (opens new window)

Signature

public Craft\AssetTransformModel, null getTransformByHandle ( $handle )

# getTransformFilename()

Return the filename used by the Transform Index for the File.

View source (opens new window)

Arguments

Returns

mixed

Signature

public mixed getTransformFilename ( Craft\AssetFileModel $file, Craft\AssetTransformIndexModel $index )

# getTransformIndex()

Get a transform index row. If it doesn't exist - create one.

View source (opens new window)

Arguments

Returns

Craft\AssetTransformIndexModel

Signature

public Craft\AssetTransformIndexModel getTransformIndex ( Craft\AssetFileModel $file, $transform )

# getTransformIndexModelByFileIdAndHandle()

Get a transform index model by a row id.

View source (opens new window)

Arguments

Returns

Craft\AssetTransformIndexModel, null (opens new window)

Signature

public Craft\AssetTransformIndexModel, null getTransformIndexModelByFileIdAndHandle ( $fileId, $transformHandle )

# getTransformIndexModelById()

Get a transform index model by a row id.

View source (opens new window)

Arguments

Returns

Craft\AssetTransformIndexModel, null (opens new window)

Signature

public Craft\AssetTransformIndexModel, null getTransformIndexModelById ( $transformId )

# getTransformSubfolder()

Return a subfolder used by the Transform Index for the File.

View source (opens new window)

Arguments

Returns

mixed, string (opens new window)

Signature

public mixed, string getTransformSubfolder ( Craft\AssetFileModel $file, Craft\AssetTransformIndexModel $index )

# getTransformSubpath()

Get a transform subpath used by the Transform Index for the File.

View source (opens new window)

Arguments

Returns

string (opens new window)

Signature

public string getTransformSubpath ( Craft\AssetFileModel $file, Craft\AssetTransformIndexModel $index )

# getUrlForTransformByAssetAndTransformIndex()

Get the URL for transform for the given asset, by the given transform index model

View source (opens new window)

Arguments

Returns

string (opens new window)

Signature

public string getUrlForTransformByAssetAndTransformIndex ( Craft\AssetFileModel $file, Craft\AssetTransformIndexModel $transformIndexModel )

# getUrlForTransformByIndexId()

Get URL for Transform by TransformIndexId.

View source (opens new window)

Arguments

  • $transformId

Returns

string (opens new window)

Signature

public string getUrlForTransformByIndexId ( $transformId )

# getUrlForTransformByTransformIndex()

Get URL for Transform by the transform index model.

View source (opens new window)

Arguments

Returns

string (opens new window)

Signature

public string getUrlForTransformByTransformIndex ( Craft\AssetTransformIndexModel $transformIndexModel )

# normalizeTransform()

Normalize a transform from handle or a set of properties to an AssetTransformModel.

View source (opens new window)

Arguments

  • $transform (mixed)

Returns

Craft\AssetTransformModel, null (opens new window)

Throws

Signature

public Craft\AssetTransformModel, null normalizeTransform ( $transform )

# queueSourceForDeletingIfNecessary()

Deletes an image local source if required by config.

View source (opens new window)

Arguments

  • $imageSource

Returns

null (opens new window)

Signature

public null queueSourceForDeletingIfNecessary ( $imageSource )

# saveTransform()

Saves an asset transform.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Throws

Signature

public boolean saveTransform ( Craft\AssetTransformModel $transform )

# setActiveTransformIndexModel()

Signature

public void setActiveTransformIndexModel ( Craft\AssetTransformIndexModel $index )

# storeLocalSource()

Store a local image copy to a destination path.

View source (opens new window)

Arguments

  • $localCopy
  • $destination

Returns

null (opens new window)

Signature

public null storeLocalSource ( $localCopy, $destination )

# storeTransformIndexData()

Store a transform index data by it's model.

View source (opens new window)

Arguments

Returns

Craft\AssetTransformIndexModel

Signature

public Craft\AssetTransformIndexModel storeTransformIndexData ( Craft\AssetTransformIndexModel $index )

# validateTransformIndexResult()

Validates a transform index result to see if the index is still valid for a given file.

View source (opens new window)

Arguments

Returns

boolean (opens new window) – Whether the index result is still valid

Signature

public boolean validateTransformIndexResult ( $result, Craft\AssetTransformModel $transform, Craft\AssetFileModel $file )