assetRequest
If defined the Editor will display a directory/file icon. I.e. "..." in fields where media is supported, as well as binding to the "insert image" button in the html WYSIWIG editor. If the icon is clicked by an author the function is called.
Examples
"assetRequest": function( mediaRequested,
returnType,
callback ,
attributes) {
// myfunction that opens an asset
// browser or uploader and then calls
// callback(URL|HTML|UrlHeightWidth)
},
// example function to be called by assetRequest
var assetRequestFunction = function(mediaRequested, returnType, callback) {
if (mediaRequested === 'image') {
var $modal = $('.modal.img-upload'),
$images = $('.asset-img-gallery img'),
imgClickHandler = function () {
if (returnType === 'HTML') {
callback('<img src="' + $(this).data('img') + '"/>');
} else {
callback($(this).data('img'));
}
$modal.modal('hide');
$images.off('click', imgClickHandler);
};
$images.on('click', imgClickHandler);
$modal.modal({
backdrop: 'static'
});
}
Values
Type function
Callback arguments
The callback receives the following arguments when it is executed.
-
mediaRequested string
Determine the type of media
Possible values:"audio"
"image"
"video"
"resource"
-
returnType string
Let the function know whether to supply HTML or a URL or an object that contains image's url, width and height.
Possible values:"HTML"
"URL"
"UrlHeightWidth"
-
callback callback
Function that must be executed once the
HTML
,URL
orUrlHeightWidth
is ascertained.-
data string | UrlHeightWidth
-
-
attributes object
Attributes of media to be used in
assetRequest
-
alt string
The alternative text for an image.
-
height string
-
src string
The url of an asset.
-
width string
-