Skip to content
NewMastershot Studio is open: a video editor with no watermark on anything you export. Try it free

Options, methods and events

Every option, property, method and event the editor has, in one place.

Everything the editor's script exports, and everything an editor has. The guides explain each one with examples.

Making an editor

ExportDoes
appendDefaultEditor(target, options)Puts an editor in target, an element or a selector, and returns it
appendDefaultEditors(selector, options)One editor in each element that matches; returns them all
openDefaultEditor(options)Opens an editor in a modal over the page. It also has show() and hide()
defineDefaultCustomElements(options)Registers <mastershot-editor>, with options for each one. Resolves once it's registered
processImage(src, options)Edits a file without showing an editor and resolves with the result
getEditorDefaults(options)The default options with yours over them
createDefaultImageWriter(options)A writer with saving options

appendEditor, appendEditors, openEditor and defineCustomElements do the same without the defaults, so an editor with no file shows no file chooser. Use the Default ones unless you're setting everything yourself.

Options

Pass options when you make an editor. Every one is also a property you can read and set later, as in editor.utils = ["crop"].

OptionIs
srcThe file to open: a File, a Blob, or a URL
licenseKeyYour license key, on a live site
utilsThe tools to show: crop, trim, redact, filter, resize
utilThe tool it opens on
theme"light", "dark" or "auto"
imageStateEdits to open the file with
imageWriterHow the file is saved
imageCropAspectRatioHolds the crop to one shape, as width Ă· height
imageMaxDurationThe most seconds of a video that can be kept
imageMinDurationRefuses a video shorter than this, in seconds
cropSelectPresetOptionsThe crop shapes and sizes to choose from
cropEnableSelectPreset, cropEnableButtonRotateLeft, cropEnableButtonRotateRight, cropEnableRotationInput, cropEnableButtonFlipHorizontal, cropEnableButtonFlipVerticalParts of the crop tool, all shown by default
cropRotationRangeHow far the straighten slider goes each way, in radians
trimEnableSplitLets your visitor keep several parts of a video
enableToolbar, enableButtonExport, enableButtonClose, enableButtonRevert, enableNavigateHistoryThe buttons
enableUtilsThe tool switcher
enableBrowseImage, enableDropImageChoosing or dropping a file when the editor has none
acceptThe files the chooser offers
muteAudioPlays videos silent while editing (the default). false plays their sound
localeThe button labels
willProcessImageRuns on Done with the edits; return false to stop the save
willCloseRuns on Cancel; return false to keep the editor open
willRevertRuns on Revert; return false to keep the edits
disabledStops your visitor from making changes
statusA message shown over the editor, such as "Uploading…"
id, classSet on the editor's box
enableAutoHide, enableAutoDestroyThe modal hides once the file is saved, and is removed once it's hidden. Both true by default

Properties

Each part of the edits is a property with image in front, such as imageCrop, imageRotation, imageFlipX, imageFlipY, imageRedaction, imageColorMatrix, imageTargetSize, imageTrim and imageVolume. imageState is all of them at once.

Read-only: imageFile, imageSize, imageAspectRatio, imageCropSize, imageDuration, imageLoadState, imageProcessState, and element, the editor's box.

Methods

MethodDoes
on(event, handler)Listens for an event. Returns a function that stops listening
loadImage(src, imageState?)Opens a file, with edits if you give them
processImage()Saves the file as if Done were pressed, and resolves with the result
abortLoadImage(), abortProcessImage()Stops opening or saving a file
removeImage()Closes the file
close()Sends close, as Cancel does
destroy()Takes the editor off the page
history.undo(), history.redo(), history.revert()Undo, redo and revert
play(), pause(), togglePlayPause(), isPaused()Plays a video
mute(), unmute(), toggleMute()A video's sound while editing
getDuration(), getCurrentTime(), setCurrentTime(seconds)Where a video is
show(), hide()The modal, from openDefaultEditor

Events

Listen with editor.on("process", handler). The <mastershot-editor> element sends each one as a DOM event named mastershot:<event>, with what the handler would get in event.detail.

EventSent
loadA file is open: { src, dest, size }
loadstart, loadprogress, loaderror, loadabortWhile a file opens
updateAny edit, with the new imageState
processThe file is saved: { src, dest, imageState }, and store if it was uploaded
processstart, processprogress, processerror, processabortWhile a file is saved
undo, redo, revert, writehistoryThe history changed
selectutilYour visitor switched tools, with the util's name
play, pauseA video started or stopped
closeCancel was pressed
show, hideThe modal opened or closed
ready, destroyThe editor is ready, or gone

Helpers

isSupported() says whether the browser can run the editor: any current Chrome, Edge, Firefox or Safari can. blobToFile(blob, name) turns a Blob into a File. degToRad(degrees) turns degrees into the radians imageRotation takes.

Stuck, or something isn't working? Email [email protected] with what you tried. If a photo or video won't open, send it if you can, and we'll make it work.