UNA
BxDolTranscoderImage Class Reference
Inheritance diagram for BxDolTranscoderImage:
BxDolTranscoder iBxDolFactoryObject BxDolFactory iBxDolFactoryObject

Public Member Functions

 isMimeTypeSupported ($sMimeType)
 
 getFileUrl ($mixedHandler)
 
 getFileUrlNotReady ($mixedHandler)
 
- Public Member Functions inherited from BxDolTranscoder
 onDeleteFileLocal ($iFileId)
 
 onDeleteFileOrig ($mixedHandler)
 
 registerHandlers ()
 
 unregisterHandlers ()
 
 cleanup ()
 
 getStorage ()
 
 getDb ()
 
 isMimeTypeSupported ($sMimeType)
 
 getFileUrl ($mixedHandler)
 
 getFileUrlById ($mixedHandler)
 
 isFileReady ($mixedHandler, $isCheckOutdated=true)
 
 transcode ($mixedHandler, $iProfileId=0)
 
 prune ()
 
 getFileUrlNotReady ($mixedHandler)
 
 getFilterParams ($sName)
 

Additional Inherited Members

- Static Public Member Functions inherited from BxDolTranscoder
static getObjectInstance ($sObject)
 
static pruning ()
 
static processQueue ($bQueuePruning=true)
 
static processCompleted ()
 
static registerHandlersArray ($mixed)
 
static registerHandlersSystem ()
 
static unregisterHandlersArray ($mixed)
 
static cleanupObjectsArray ($mixed)
 
static onAlertResponseFileDeleteLocal ($oAlert, $sObject)
 
static onAlertResponseFileDeleteOrig ($oAlert, $sObject)
 
- Protected Member Functions inherited from BxDolTranscoder
 __construct ($aObject, $oStorage)
 
- Static Protected Member Functions inherited from BxDolTranscoder
static getTranscoderObjects ()
 

Detailed Description

This class transcodes images on the fly. Transcoded image is saved in the specified storage engine and next time ready image is served.

To add image transcoder object add record to 'sys_objects_transcoder' table:

  • object - name of the transcoder object, in the format: vendor prefix, underscore, module prefix, underscore, image size name; for example: bx_images_thumb.
  • storage_object - name of the storage object to store transcoded data, the specified storage object need to be created too,
    See also
    BxDolStorage.
  • source_type - type of the source, where is source image is taken from, available options 'Storage' and 'Folder' for now.
  • source_params - source_type params, each source_type can have own set of params, please read futher for more info about particular source_types, serialized array of params is stored here.
  • private - how to store transcoded data:
    • no - store transcoded data publicly.
    • yes - store transcoded data privately.
    • auto - detect automatically, not supported for 'Folder' source type.
  • atime_tracking - track last access time to the transcoded data, allowed values 0 - disables or 1 - enabled.
  • atime_pruning - prune transcoded images by last access time, if last access time of the image is older than atime_pruning seconds - it is deleted, it works when atime_tracking is enabled
  • ts - unix timestamp of the last change of transcoder parameters, if transcoded image is older than this value - image is deleted and transcoded again.

Then you need to add image filters to 'sys_transcoder_filters' table:

  • transcoder_object - name of the transcoded object to apply filter to.
  • filter - filter name, please read futher for available filters.
  • filter_params - serialized array of filter params, please read futher for particular filters params.
  • order - if there are several filters for one object, they will be applied in this order.

'Folder' source types: This source type is some folder with original images for the transcoding, the identifier of the image (handler) is file name. The params are the following:

  • path - path to the folder with original images This source type has some limitation:
  • automatic detection of private files is not supported
  • transcoded file is not automaticlaly deleted/renewed if original file is changed

'Storage' source type: The source of original files is Storage engine, the identifier of the image (handler) is file id. The params are the following:

  • object - name of the Storage object

Available filters:

  • Resize - this filter resizes original image, the parameters are the following:
    • w - width of resulted image.
    • h - height of resulted image.
    • square_resize - make resulted image square, even of original image is not square, 'w' and 'h' parameters must be the same.
    • crop_resize - crop image to destination size with filling whole area of destination size.
    • force_type - always change type of the image to the specified type: jpg, png, gif.
  • Grayscale - make image grayscale, there is no parameters for this filter

Automatic deletetion of associated data is supported - in the case if original or transcoded file is deleted, but you need to register alert handlers, just call registerHandlers () function to register handler (for example, during module installation) and call unregisterHandlers () function to unregister handlers (for example, during module uninstallation)

Example of usage:

$oTranscoder = BxDolTranscoderImage::getObjectInstance('bx_images_thumb'); // change images transcode object name to your own
$oTranscoder->registerHandlers(); // make sure to call it only once! before the first usage, no need to call it every time
$sTranscodedImageUrl = $oTranscoder->getFileUrl('my_dog.jpg'); // the name of file, in the case of 'Folder' storage type this is file name
echo 'My dog : <img src="' . $sUrl . '" />'; // transcoded(resized and/or grayscaled) image will be shown, according to the specified filters

Member Function Documentation

◆ getFileUrl()

BxDolTranscoderImage::getFileUrl (   $mixedHandler)

Get transcoded file url. If transcoded file is ready then direct url to the file is returned. If there is no transcoded data available, then special url is returned, upon opening this url image is transcoded automatically and redirects to the ready transcoed image.

Parameters
$mixedHandler- file handler
Returns
file url, or false on error.

◆ getFileUrlNotReady()

BxDolTranscoderImage::getFileUrlNotReady (   $mixedHandler)

Get file url when file isn't transcoded yet

◆ isMimeTypeSupported()

BxDolTranscoderImage::isMimeTypeSupported (   $sMimeType)

check if transcoder suppors given file mime type


The documentation for this class was generated from the following file: