- System Apps
- Core Apps
- Premium Apps
- Template Apps
- Language Apps
- Tailored Apps
- Studio Overview
- Adding Apps
- Paid Levels
- Remote Storage
- DB cluster
- Code Convention
- Code Quality
- Common Mistakes
- Profiles structure
- Creating a Module App
- Creating a Template App
- Creating a Language App
- Creating a Payment Provider Integration App
- Creating an App Auto-update Script
- Studio Apps
- Handling Date and Time
- Browseable categories
- Search Forms
- Images Transcoder
- Video Transcoder
- List of personal data and sensitive content in the DB
- Auto generated documentation
This API automatically resize and store images, the whole procedure is very simplified.
The advantages of this system:
- Less code to write - so you can concentrate on the main functionality
- Less space usage - only usable data is transcoded and unused data can be automatically deleted
- Flexibility - you can change image filters (for example, new image dimentions) and all images will be transcoded automatically, upon first access
- Security - the transcoded image can have the same security setting as original
Images Transcoder is working together with Storage Engine to store transcoded data. So, for example, you can store transcoded data on Amazon S3 with reduced redundancy option to save some money.
To add image transcoder object add record to
object- name of the transcoder object, in the format: vendor prefix, underscore, module prefix, underscore, image size name; for example:
storage_object- name of the storage object to store transcoded data, the specified storage object need to be created too.
source_type- type of the source, where is source image is taken from, available options
source_typecan 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
atime_pruning- prune transcoded images by last access time, if last access time of the image is older than
atime_pruningseconds - it is deleted, it works when
ts- unix timestamp of the last change of transcoder parameters, if transcoded image is older than this value - image is deleted and transcoded again.
Folder- 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- 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
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: png, jpg or 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. All you need is 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).
bx_import('BxDolTranscoderImage'); $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->getImageUrl('my_dog.jpg'); // the name of file, in the case of 'Folder' storage type this is filename echo 'My dog : <img src="' . $sTranscodedImageUrl . '" />'; // transcoded(resized and/or grayscaled) image will be shown, according to the specified filters