Image Upload
These options control how the editor handles image uploads, including the upload endpoint, custom upload handlers, and the file picker dialog.
Options
| Option | Type | Default | Description |
|---|---|---|---|
automatic_uploads | boolean | true | Automatically upload images that are added to the editor as blob URIs (e.g. from paste or drag-and-drop). |
images_upload_url | string | '' | Server endpoint URL that accepts image uploads. The editor sends a POST request with the image as form data. |
images_upload_base_path | string | '' | Base path prepended to the filename returned by the upload endpoint. |
images_upload_credentials | boolean | false | Send cookies and authentication headers with upload requests (sets withCredentials on the XMLHttpRequest). |
images_upload_handler | function | — | Custom upload handler function. Receives a blobInfo object and a progress callback. Must return a Promise that resolves with the uploaded image URL. |
images_reuse_filename | boolean | false | Reuse the original blob filename when uploading instead of generating a new one. |
images_replace_blob_uris | boolean | true | Replace temporary blob URIs in content with the final URL returned by the upload handler. |
images_file_types | string | 'jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp' | Comma-separated list of image file extensions that are accepted for upload. |
Accessibility
| Option | Type | Default | Description |
|---|---|---|---|
a11y_advanced_options | boolean | false | Show an additional "Decorative image" toggle in the image dialog. When checked, the alt text field is cleared and disabled. |
File picker
| Option | Type | Default | Description |
|---|---|---|---|
file_picker_callback | function | — | Custom file picker handler that opens when the user clicks the browse button in link, image, or media dialogs. Receives a callback to set the picked URL, the current field value, and metadata about the picker type. |
file_picker_types | string | — | Space-separated list of picker types to enable: 'file', 'image', and/or 'media'. If omitted, all types are enabled when file_picker_callback is set. |
file_picker_validator_handler | function | — | Validation function for URLs entered or selected in the file picker. |
Example
editor42.init({
selector: 'textarea',
automatic_uploads: true,
images_upload_url: '/api/upload',
images_upload_base_path: '/uploads/',
images_upload_credentials: true,
images_file_types: 'jpeg,jpg,png,gif,webp',
a11y_advanced_options: true,
file_picker_callback: (callback, value, meta) => {
const input = document.createElement('input');
input.type = 'file';
input.accept = 'image/*';
input.onchange = () => {
const file = input.files[0];
const reader = new FileReader();
reader.onload = () => {
callback(reader.result, { title: file.name });
};
reader.readAsDataURL(file);
};
input.click();
}
});