Skip to content

EmbedExtensionsComponent.registerExtensions method

EmbedExtensionsComponent › registerExtensions

Registers the specified file extensions with the given embed type in the Obsidian app. The extensions will be automatically unregistered when the component is unloaded.

The registration is all or nothing: Obsidian throws for an extension that is already registered (by the core or by another plugin), and in that case every extension this call registered before the conflict is unregistered again before the error is rethrown. An extension registered by someone else is never unregistered.

The creator serves every surface that loads an embed: ![[file.ext#subpath]] in Reading view and Live Preview, canvas file nodes and the page-preview hover popover. It receives the link's subpath with its leading #, or an empty string. Returning null makes Obsidian fall back to its generic file embed.

Signature:

registerExtensions(extensions: string[], embedCreator: EmbedCreator): void

Parameters:

ParameterTypeDescription
extensionsstring[]An array of file extensions to register.
embedCreatorEmbedCreatorThe embed creator function to associate with the extensions.

Returns: void

Example:

component.registerExtensions(['ext1', 'ext2'], (context, file, subpath) => new MyEmbedComponent(context, file, subpath));