Skip to main content

Image Upload

These options control how the editor handles image uploads, including the upload endpoint, custom upload handlers, and the file picker dialog.

Options

OptionTypeDefaultDescription
automatic_uploadsbooleantrueAutomatically upload images that are added to the editor as blob URIs (e.g. from paste or drag-and-drop).
images_upload_urlstring''Server endpoint URL that accepts image uploads. The editor sends a POST request with the image as form data.
images_upload_base_pathstring''Base path prepended to the filename returned by the upload endpoint.
images_upload_credentialsbooleanfalseSend cookies and authentication headers with upload requests (sets withCredentials on the XMLHttpRequest).
images_upload_handlerfunctionCustom upload handler function. Receives a blobInfo object and a progress callback. Must return a Promise that resolves with the uploaded image URL.
images_reuse_filenamebooleanfalseReuse the original blob filename when uploading instead of generating a new one.
images_replace_blob_urisbooleantrueReplace temporary blob URIs in content with the final URL returned by the upload handler.
images_file_typesstring'jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp'Comma-separated list of image file extensions that are accepted for upload.

Accessibility

OptionTypeDefaultDescription
a11y_advanced_optionsbooleanfalseShow an additional "Decorative image" toggle in the image dialog. When checked, the alt text field is cleared and disabled.

File picker

OptionTypeDefaultDescription
file_picker_callbackfunctionCustom 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_typesstringSpace-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_handlerfunctionValidation 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();
}
});