tinymce.EditorUpload

TinyMCE Editor Upload API Handles image uploads, updates undo stack and patches over various internal functions.

Examples

// Apply a new filter within the image scan.
tinymce.activeEditor.EditorUpload.addFilter((image) => {
  const maxSize = 1920 * 1080;
  const imageSize = image.width * image.height;
  return imageSize < maxSize;
});

// Upload all valid images in the editor
tinymce.activeEditor.EditorUpload.uploadImages();

// Scan the editor for valid images
tinymce.activeEditor.EditorUpload.scanForImages();

Summary

Properties

Name Type Summary Defined by

blobCache

Object

Cache of blob elements created in an editor instance.

EditorUpload

Methods

Name Summary Defined by

addFilter()

Adds a custom filter that controls the images which are included in the scan. Images must return true on every added filter to be considered valid.

EditorUpload

destroy()

Resets the blob data and upload status of all uploaded images. Called automatically on editor.remove. This method is not recommended for integration.

EditorUpload

scanForImages()

Scans the editor content for valid image elements and generates blob information for each image.

EditorUpload

uploadImages()

Uploads all the data uri/blob uri images scanned from the editor content to the server.

EditorUpload

uploadImagesAuto()

Uploads all data uri/blob uri images to the server only when automatic uploads are enabled.

EditorUpload

Methods

addFilter()

addFilter(filter: Function)

Adds a custom filter that controls the images which are included in the scan. Images must return true on every added filter to be considered valid.

Examples

// Filter which images are uploaded.
tinymce.activeEditor.EditorUpload.addFilter((image) => {
  const maxSize = 1920 * 1080;
  const imageSize = image.width * image.height;
  return imageSize < maxSize;
});

Parameters

  • filter (Function) - Function which filters each image upload.


destroy()

destroy()

Resets the blob data and upload status of all uploaded images. Called automatically on editor.remove. This method is not recommended for integration.


scanForImages()

scanForImages(): Promise

Scans the editor content for valid image elements and generates blob information for each image.

Return value

  • Promise - Promise instance with element object and blob information for each image.


uploadImages()

uploadImages(): Promise

Uploads all the data uri/blob uri images scanned from the editor content to the server.

Return value

  • Promise - Promise instance with images and status for each image.


uploadImagesAuto()

uploadImagesAuto(): Promise

Uploads all data uri/blob uri images to the server only when automatic uploads are enabled.

Return value

  • Promise - Promise instance with images and status for each image.