Textbox.io 2.x Documentation : editor.content.uploadImages()

Add all Base64 images from an editor's content to the Textbox.io Services upload queue with editor.content.uploadImages()

If editor.content.uploadImages() is called before an existing image upload has completed, identified Base64 images will be appended to the upload queue. Images that are not Base64 encoded will be ignored. 

Upon completion of the queue,  editor.content.uploadImages() triggers a callback function. This callback function is passed a result set containing a list of all images uploaded during since editor.content.uploadImages()  was called. Each item in the result set contains a DOM reference to the <img>, and a status (success/failure) for that image upload.

  • A success status means that the <img> should now contain a valid  src attribute to uploaded image. 
  • A false status implies that the image has failed to upload. After a failed upload, the image will still be Base64 encoded in the editor content. If   editor.content.uploadImages() is called again, the editor will pick up the failed image and try again.

Example

editor.content.uploadImages()
var callback = function (results) {
	console.log('Images have finished uploading.');
	
	results.forEach(function (result) {
		console.log('upload successful: ' + result.success);
		console.log('the image element ',  result.element);
	});
};
 
// Add all Base64 images from editor content to the upload queue
editor.content.uploadImages(callback);

Parameters

callbackFunction

Receives an array of objects with the upload status and DOM reference of each image that was uploaded.

Objects are in the form of:

var result = {
  success: true,
  element: reference
}

Returns

No return value.