Receives an img
element of containing the preview of a file.
$au.imageUploaderFlash('uploaderID').files().get(index).getPreview(previewParams);
Type: Object
The object containing three properties - callback
(function with an img
argument), size
of the preview you need to return and mode
to specify how to interpret the size (whether to fit into the square of this size or automatically crop the preview). The latter param accepts the values of thumbnailFitMode.
This function is asyncronous. You pass a previewParams
instance which contains a callback
. When the preview image is ready, the callback is called and this img
element is passed there.
As the preview appears not immediately, it makes sense to display some placeholder instead of a preview until the image is ready. For example, you can use a div
element with class equal to the iconCssClass value.
Inside the callback you can access the current file instance using this
.
For example, let's imagine you need to receive a preview for the first element in the upload list of 150px. The code may look like this:
var f = $au.imageUploaderFlash("Uploader1").files().get(0); $("#preview").html("<div class=" + f.iconCssClass() + "></div>"); f.getPreview({ size: 150, mode: 'crop', callback: function(img) { $("#preview").html(img); } });