AssetTransformsService

Type
Class
Namespace
Craft
Inherits
Craft\AssetTransformsService » Craft\BaseApplicationComponent » CApplicationComponent » CComponent
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

Public Properties

PropertyDescription
$behaviorsarray – The behaviors that should be attached to this component.

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
canGetProperty()Determines whether a property can be read.
canSetProperty()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()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()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()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
eagerLoadTransforms()Eager-loads transform indexes for a given set of file IDs.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
ensureTransformUrlByIndexModel()Get a transform URL by the transform index model.
evaluateExpression()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()Returns the list of attached event handlers for an event.
getIsInitialized()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()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
init()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()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

Arguments

Returns

null

Signature

public null deleteAllTransformData ( Craft\AssetFileModel $file )

deleteCreatedTransformsForFile()

Delete created transforms for a file.

View source

Arguments

Signature

public void deleteCreatedTransformsForFile ( Craft\AssetFileModel $file )

deleteQueuedSourceFiles()

Delete all image sources queued up for deletion.

View source

Returns

null

Signature

public null deleteQueuedSourceFiles ( )

deleteThumbnailsForFile()

Delete all the generated thumbnails for the file.

View source

Arguments

Returns

null

Signature

public null deleteThumbnailsForFile ( Craft\AssetFileModel $file )

deleteTransform()

Deletes an asset transform by it's id.

View source

Arguments

Returns

boolean

Throws

Signature

public boolean deleteTransform ( $transformId )

deleteTransformIndex()

Delete a transform index by.

View source

Arguments

Returns

null

Signature

public null deleteTransformIndex ( $indexId )

deleteTransformIndexDataByFileId()

Delete transform records by a file id.

View source

Arguments

Returns

null

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

Arguments

Returns

mixed, string

Throws

Signature

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

eagerLoadTransforms()

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

View source

Arguments

  • $files (Craft\AssetFileModel[]) – The files to eager-load tranforms for
  • $transforms (array) – The transform definitions to eager-load

Returns

void

Signature

public void eagerLoadTransforms ( $files, $transforms )

ensureTransformUrlByIndexModel()

Get a transform URL by the transform index model.

View source

Arguments

Returns

string

Throws

Signature

public string ensureTransformUrlByIndexModel ( Craft\AssetTransformIndexModel $index )

generateTransform()

Generate a transform by a created index.

View source

Arguments

Returns

null

Signature

public null generateTransform ( Craft\AssetTransformIndexModel $index )

getActiveTransformIndexModel()

View source

Returns

mixed

Signature

public mixed getActiveTransformIndexModel ( )

getAllCreatedTransformsForFile()

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

View source

Arguments

Returns

array

Signature

public array getAllCreatedTransformsForFile ( Craft\AssetFileModel $file )

getAllTransforms()

Returns all named asset transforms.

View source

Arguments

Returns

array

Signature

public array getAllTransforms ( $indexBy = null )

getCachedCloudImageSize()

Get the size of max cached cloud images dimension.

View source

Returns

integer

Signature

public integer getCachedCloudImageSize ( )

getLocalImageSource()

Get a local image source to use for transforms.

View source

Arguments

  • $file

Returns

mixed

Throws

Signature

public mixed getLocalImageSource ( Craft\AssetFileModel $file )

getPendingTransformIndexIds()

Returns a list of pending transform index IDs.

View source

Returns

array

Signature

public array getPendingTransformIndexIds ( )

getThumbServerPath()

Get a thumb server path by file model and size.

View source

Arguments

  • $fileModel
  • $size

Returns

boolean, string

Throws

Signature

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

getTransformByHandle()

Returns an asset transform by its handle.

View source

Arguments

Returns

Craft\AssetTransformModel, null

Signature

public Craft\AssetTransformModel, null getTransformByHandle ( $handle )

getTransformFilename()

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

View source

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

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

Arguments

Returns

Craft\AssetTransformIndexModel, null

Signature

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

getTransformIndexModelById()

Get a transform index model by a row id.

View source

Arguments

Returns

Craft\AssetTransformIndexModel, null

Signature

public Craft\AssetTransformIndexModel, null getTransformIndexModelById ( $transformId )

getTransformSubfolder()

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

View source

Arguments

Returns

mixed, string

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

Arguments

Returns

string

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

Arguments

Returns

string

Signature

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

getUrlForTransformByIndexId()

Get URL for Transform by TransformIndexId.

View source

Arguments

  • $transformId

Returns

string

Signature

public string getUrlForTransformByIndexId ( $transformId )

getUrlForTransformByTransformIndex()

Get URL for Transform by the transform index model.

View source

Arguments

Returns

string

Signature

public string getUrlForTransformByTransformIndex ( Craft\AssetTransformIndexModel $transformIndexModel )

normalizeTransform()

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

View source

Arguments

  • $transform (mixed)

Returns

Craft\AssetTransformModel, null

Throws

Signature

public Craft\AssetTransformModel, null normalizeTransform ( $transform )

queueSourceForDeletingIfNecessary()

Deletes an image local source if required by config.

View source

Arguments

  • $imageSource

Returns

null

Signature

public null queueSourceForDeletingIfNecessary ( $imageSource )

saveTransform()

Saves an asset transform.

View source

Arguments

Returns

boolean

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

Arguments

  • $localCopy
  • $destination

Returns

null

Signature

public null storeLocalSource ( $localCopy, $destination )

storeTransformIndexData()

Store a transform index data by it's model.

View source

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

Arguments

Returns

boolean – Whether the index result is still valid

Signature

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