MediaEmbedConfig
The configuration of the media embed features.
Read more about configuring the media embed feature.
ClassicEditor
.create( {
mediaEmbed: ... // Media embed feature options.
} )
.then( ... )
.catch( ... );
See all editor options.
Properties
elementName : string | undefinedmodule:media-embed/mediaembedconfig~MediaEmbedConfig#elementNameOverrides the element name used for "semantic" data.
This is not relevant if
config.mediaEmbed.previewsInDatais set totrue.When not set, the feature produces the
<oembed>tag:<figure class="media"> <oembed url="https://url"></oembed> </figure>Copy codeTo override the element name with, for instance, the
o-embedname:mediaEmbed: { elementName: 'o-embed' }Copy codeThis will produce semantic data with the
<o-embed>tag:<figure class="media"> <o-embed url="https://url"></o-embed> </figure>Copy codeDefaults to
'oembed'extraProviders : Array<MediaEmbedProvider> | undefinedmodule:media-embed/mediaembedconfig~MediaEmbedConfig#extraProvidersThe additional media providers supported by the editor. This configuration helps extend the default
providers.ClassicEditor .create( { plugins: [ MediaEmbed, ... ], mediaEmbed: { extraProviders: [ { name: 'extraProvider', url: /^example\.com/media/(\w+)/, html: match => '...' }, ... ] } } ) .then( ... ) .catch( ... );Copy codeSee the provider syntax to learn more.
previewsInData : boolean | undefinedmodule:media-embed/mediaembedconfig~MediaEmbedConfig#previewsInDataControls the data format produced by the feature.
When
false(default), the feature produces "semantic" data, i.e. it does not include the preview of the media, just the<oembed>tag with theurlattribute:<figure class="media"> <oembed url="https://url"></oembed> </figure>Copy codeWhen
true, the media is represented in the output in the same way it looks in the editor, i.e. the media preview is saved to the database:<figure class="media"> <div data-oembed-url="https://url"> <iframe src="https://preview"></iframe> </div> </figure>Copy codeNote: Media without preview are always represented in the data using the "semantic" markup regardless of the value of the
previewsInData. Learn more about different kinds of media in theconfig.mediaEmbed.providersconfiguration description.Defaults to
falseproviders : Array<MediaEmbedProvider> | undefinedmodule:media-embed/mediaembedconfig~MediaEmbedConfig#providersThe default media providers supported by the editor.
The names of providers with rendering functions (previews):
- "dailymotion",
- "spotify",
- "youtube",
- "vimeo"
The names of providers without rendering functions:
- "instagram",
- "twitter",
- "googleMaps",
- "flickr",
- "facebook"
See the provider syntax to learn more about different kinds of media and media providers.
Note: The default media provider configuration may not support all possible media URLs, only the most common are included.
Media without rendering functions are always represented in the data using the "semantic" markup. See
config.mediaEmbed.previewsInDatato learn more about possible data outputs.The priority of media providers corresponds to the order of configuration. The first provider to match the URL is always used, even if there are other providers that support a particular URL. The URL is never matched against the remaining providers.
To discard all default media providers, simply override this configuration with your own definitions:
ClassicEditor .create( { plugins: [ MediaEmbed, ... ], mediaEmbed: { providers: [ { name: 'myProvider', url: /^example\.com/media/(\w+)/, html: match => '...' }, ... ] } } ) .then( ... ) .catch( ... );Copy codeYou can take inspiration from the default configuration of this feature which you can find in: https://github.com/ckeditor/ckeditor5-media-embed/blob/master/src/mediaembedediting.js
To extend the list of default providers, use
config.mediaEmbed.extraProviders.To remove certain providers, use
config.mediaEmbed.removeProviders.removeProviders : Array<string> | undefinedmodule:media-embed/mediaembedconfig~MediaEmbedConfig#removeProvidersThe list of media providers that should not be used despite being available in
config.mediaEmbed.providersandconfig.mediaEmbed.extraProvidersmediaEmbed: { removeProviders: [ 'youtube', 'twitter' ] }Copy codestyles : MediaStyleConfig | undefinedmodule:media-embed/mediaembedconfig~MediaEmbedConfig#stylesThe media embed style feature configuration.
Available out of the box: five built-in alignment styles —
'alignLeft','alignBlockLeft','alignCenter'(default),'alignBlockRight','alignRight'.Restrict the set to a subset of built-ins:
mediaEmbed: { styles: { options: [ 'alignBlockLeft', 'alignCenter', 'alignBlockRight' ] } }Copy codeOverride fields of a built-in by re-declaring with the same
name:mediaEmbed: { styles: { options: [ { name: 'alignCenter', title: 'Center' }, 'alignLeft', 'alignRight' ] } }Copy codeRegister a custom (e.g. semantical) style by supplying a complete definition:
import sideIcon from 'path/to/icon.svg'; mediaEmbed: { styles: { options: [ 'alignCenter', { name: 'side', title: 'Side media', icon: sideIcon, className: 'media-style-side' } ] } }Copy codeWhen omitted, all five built-in styles are available.
toolbar : Array<ToolbarConfigItem | MediaStyleDropdownDefinition> | undefinedmodule:media-embed/mediaembedconfig~MediaEmbedConfig#toolbarItems to be placed in the media embed toolbar. This option requires adding
MediaEmbedToolbarto the plugin list.Each entry is one of:
- a component name (string) — including the built-in alignment buttons (e.g.
'mediaEmbed:alignCenter') and built-in dropdowns ('mediaEmbed:wrapText','mediaEmbed:breakText'), - a custom split-button media style dropdown definition (object) following the
MediaStyleDropdownDefinitionshape — registered alongside the built-in dropdowns and inheriting the same auto-skip / fallback-defaultItem behavior, - a generic nested toolbar grouping (
{ label, items }) — same shape as inconfig.toolbar.
mediaEmbed: { toolbar: [ 'mediaEmbed:alignCenter', { name: 'mediaEmbed:myAlignments', title: 'Alignment', items: [ 'mediaEmbed:alignBlockLeft', 'mediaEmbed:alignBlockRight' ], defaultItem: 'mediaEmbed:alignBlockLeft' } ] }Copy code- a component name (string) — including the built-in alignment buttons (e.g.