Options

Every option the image editor accepts.

Every option of the image editor. In React, options are props of ImageEditor. With the custom element and mountImageEditor, they are keys of the options object. The type is ImageEditorProps, exported from @layermetry/media-editor/react.

Address security

Use HTTPS for every server and remote media address you pass to the editor. The only HTTP exceptions are http://localhost, http://127.0.0.1 and http://[::1], for development on your own computer. Relative paths and storage keys must resolve to an HTTPS address outside local development.

Hosted requests that carry your license key, including hosted captions, are refused over HTTP to another computer. For other addresses, HTTPS is the integration rule; the SDK does not enforce it on every option.

This rule also applies to addresses in templates, stock results and callback requests. The former proxyUrl option follows the same rule; use endpointUrl in new integrations.

Custom actions

NameTypeDefaultDescription
customActionsRead-only ImageCustomAction[]NoneAdds host buttons to the selection controls and right-click menu. See Custom actions.
onCustomAction(event: ImageCustomActionEvent) => voidNoneReceives started and a final run status.

Required

NameTypeDefaultDescription
licenseKeystringnoneYour license key. See License keys.
onClose() => voidnoneCalled when the user closes the editor, and after Save & Exit and Share.

Size and layout

NameTypeDefaultDescription
widthnumber | string'100%'The width of the editor. A number is in pixels. In React, the width of the box that the component renders.
heightnumber | string'100%'The height of the editor. A number is in pixels. In React, the height of the box that the component renders.

Look

NameTypeDefaultDescription
themePartial<Record<ImageSemanticRole, string>>Layermetry paletteColors of the editor, by role. See Colors.
darkModebooleanfalseUses the dark palette.
typography{ heading, body, mono }editor fontsCSS font families for the editor's buttons and panels.
radii{ sm, md, lg, full }editor roundingCSS corner sizes for the editor's buttons and panels.
logostringnoneThe address of your logo, shown in the top bar. Use HTTPS for the logo address.
showThemeCreatorbooleanfalsetrue shows the button that opens the Customization Studio. Any other value hides it. See Editor settings.
iconsIcon-name mapBuilt-in iconsAccepts IconData or React components; see Editor settings.
uiImageUiConfigall toolsThe order, names, and visibility of tools and AI controls. See UI customization.
ui.selectionItemListConfigThe default listsHides, orders, labels and chooses display for the controls of the selected item. Applied after the default lists, on the desktop bar and on the phone.
ui.toolbarItemListConfigNoneOlder setting for toolbar groups. Its group ids are translated into control ids, with one console warning. Use ui.selection instead.
ui.customActions.shownCustomActionsUiConfig["shown"]Surface countsSets custom-action overflow counts within their maximums.

Content and services

NameTypeDefaultDescription
stockMediaApisStockMediaConfignonePexels and Unsplash. See Stock media. Use HTTPS for provider endpoints and returned media addresses.
stickersStickerConfigbuilt-in stickersSticker sources. { sources: [] } removes the Stickers tool. See Stickers and GIFs. Use HTTPS for remote source and sticker addresses.
googleFonts{ hosted: true } | { endpointUrl } | { requestFn }Built-in familiesWhere the font panel gets the whole Google Fonts catalog. See Fonts. Use HTTPS for a custom endpoint.
googleFontsApiKeystringnoneDeprecated. Sends your Google key from the browser. Use googleFonts.
mediaApiUrlstringnoneYour media server, for background removal. Use HTTPS.
filesFilenoneA picture that the editor places on the page when it starts.
createAutomatedContent({ query, contentType, metadata }) => Promise<{ success?, error? }>noneYour own text generator, behind a Generate tool. Answer { success: { type: 'text', content: string[] } }, and each line the user ticks becomes a text box.
showAttributionOverlaybooleanfalseThe starting value of Show photo credits on the canvas in the Export panel.
includeAttributionInExportbooleanfalseThe starting value of Include photo credits in the export.

AI

Configure generation through ai; expose developer tests separately with showAiPlayground.

NameTypeDefaultDescription
aiEditorAIConfigNoneConfigures transport, operations and hooks.
ai.endpointUrlstringNoneSends requests to your server without the SDK license header. Use HTTPS.
ai.requestFnAIRequestFunctionNonePasses a request and AbortSignal to your callback. Use HTTPS for requests made by your callback.
ai.hostedtrueNoneComing soon. Available only with an enterprise licence from Layermetry. Use your own endpointUrl or requestFn.
ai.headersAIHeaderValues or AIHeadersFunctionNoneSupplies same-origin endpoint headers before each attempt.
ai.credentialsomit, same-origin or includesame-originSets endpoint request cookie behavior.
ai.timeoutMsnumberNoneLimits submission time with your endpoint or function.
ai.maxRetriesnumber0Sets extra endpoint attempts with an idempotency header.
ai.idempotencyKeyHeaderstringNoneNames the server header used with positive maxRetries.
ai.brandfalse or { addToPrompt?, operations? }Brand onControls the Use brand switch in the Generate boxes. false removes it. See Brand kits.
ai.limits{ maxPerSession?: number }UnlimitedCaps attempts across operations in a session.
ai.textBoolean or operation optionsEnabled with usable AIConfigures text independently.
ai.textRewriteBoolean or operation optionsEnabled with usable AIConfigures textRewrite independently.
ai.imageBoolean or operation optionsEnabled with usable AIConfigures image independently.
ai.imageEditBoolean or operation optionsEnabled with usable AIConfigures imageEdit independently.
ai.stickerBoolean or operation optionsEnabled with usable AIConfigures sticker independently.
ai.svgPathBoolean or operation optionsEnabled with usable AIConfigures svgPath independently.
ai.onGenerationErrorAIGenerationErrorObserverNoneObserves one failure per attempt.
ai.onGenerationEventAIGenerationEventObserverNoneObserves generation lifecycle events.
ai.errorMessagesAIErrorWordingByCategorySDK wordingReplaces error wording by category.
ai.supportUrlHTTPS stringNoneAdds Contact support on account and transport failures. Use HTTPS.
showAiPlaygroundbooleanfalseAdds AI testing to the developer Studio.
templateGenerationTemplateGenerationConfigNoneConfigures generation of complete templates through a separate callback.

Choose exactly one transport. headers, credentials and retries require endpointUrl. With requestFn, only timeoutMs is accepted. The former proxyUrl name is not supported.

Operations share models, defaultModel, providers, transport and maxPerSession. Choose either models or providers. See AI providers for defaults, fields and restrictions.

Templates and storage

NameTypeDefaultDescription
onGetTemplates(filter?) => Promise<Template[]>noneLists the templates for the Templates panel. Use HTTPS for remote media addresses in returned templates.
filteranynoneA value that the editor passes to onGetTemplates.
onSaveTemplate(props) => Promise<void>noneSaves a template or a draft. Without it, no save button appears.
defaultTemplateTemplatenoneA template on the page when the editor starts. Use HTTPS for remote media addresses in the template.
templateCanvasPolicy'adopt' | 'fit' | 'place''adopt'What happens when a template has another page size.
mediaAddPolicy'fit' | 'fill' | 'none''fit'Placement of new pictures: fit inside, cover the page, or use native pixels centered. Any other value is treated as 'fit', with one console warning.
templateMetadatametadataWithContextnoneYour fields for saved templates (metadata), and your brand: brands and activeBrandId, or the one-brand colors, textStyles, and logoUrl. See Brand kits. Use HTTPS for remote brand logo addresses.
onBrandChange(brandId: string) => voidnoneCalled with the id of the active brand kit when the editor opens and on every switch. See Brand kits.
onUploadAssetUploadAssetHandlernoneStores a picture in your storage, and returns its address. Return an HTTPS address, or a storage key that resolves to one.
resolveAssetUrlResolveAssetUrlnoneTurns a stored value into an address that the browser can load. Resolve remote media to HTTPS.
assetBaseUrlstringnoneThe address that stored paths are added to. Use an HTTPS base address.
assetMetadataRecord<string, string>noneYour fields, added to every onUploadAsset call.
inlineTemplateMediabooleanfalseSaves pictures inside templates, even with onUploadAsset.

See Saving and loading and Asset storage.

Opening with files uses the picture's own pixel size for its page. A supplied defaultTemplate keeps its page size. The mediaAddPolicy setting applies to later additions; stickers keep their existing placement.

Item locking

These options are part of item locking, which is new in @layermetry/media-editor. Item locking needs version 1.0.0 or later; versions before 1.0.0 do not have these options.

With the custom element, the attributes are editor-role, allow-unlock and default-locks. onUnlock is a function, so it can only be set in props. See Item locking in your framework guide.

NameTypeDefaultDescription
role'creator' | 'adopter' | 'viewer''adopter'Who is editing. A creator ignores locks, an adopter obeys them, and a viewer changes nothing.
allowUnlockbooleanfalseLets an adopter ask to unlock items. A creator may always unlock.
onUnlock(event) => answer, or a Promise of an answernoneCalled before every unlock. Answer false, { allowed: false } or reject to refuse it. Answer { ref } to store your audit id in the unlock record.
defaultLocksobject, for example { move: true }the design's ownReplaces the design's own default locks for this session. A save never writes it.
PropTypeDefaultDescription
printPluginImagePrintPluginnoneEnables commercial PDF settings when the host supplies the optional print implementation. Uses the existing editor license. See Print export.

Events

NameTypeDefaultDescription
onExport(file: File, extras?: EditorExtras) => voidnoneReceives the exported file after Save & Exit and Share.
callback(file: File, extras?: EditorExtras) => voidnoneAn older name for onExport. Use only one of them.
onLicenseState(report: LicenseStateReport) => voidnoneCalled each time the license state changes.

See Events for the payloads, and the DOM events of the custom element.

License

NameTypeDefaultDescription
apiUrlstringhttps://api.layermetry.com/socialThe address of the license server. Use HTTPS.
statusUrlstringnoneThe address of signed status files, read when the license server cannot be reached. Use HTTPS.
renderLicenseBlocked(state: BlockedState) => ReactNodedefault screenYour own screen in place of "License Validation Failed".

See License validation.

On this page