# MediaRegistry

class

A bridge between the raw media content provider definitions and the editor view content.

It helps translating media URLs to corresponding [view elements](module_engine_view_element-ViewElement.md).

Mostly used by the [`MediaEmbedEditing`](module_media-embed_mediaembedediting-MediaEmbedEditing.md) plugin.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-media-embed/src/mediaregistry.ts#L27)

<a id="properties">

## Properties

<a id="member-locale">

### `locale: Locale`

The [`Locale`](module_utils_locale-Locale.md) instance.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-media-embed/src/mediaregistry.ts#L31)

<a id="member-providerDefinitions">

### `providerDefinitions: Array<MediaEmbedProvider>`

The media provider definitions available for the registry. Usually corresponding with the [media configuration](module_media-embed_mediaembedconfig-MediaEmbedConfig.md).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-media-embed/src/mediaregistry.ts#L37)

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( locale, config )`

Creates an instance of the [`MediaRegistry`](module_media-embed_mediaregistry-MediaRegistry.md) class.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-media-embed/src/mediaregistry.ts#L45)

#### Parameters

* `locale: Locale`

  The localization services instance.

* `config: MediaEmbedConfig`

  The configuration of the media embed feature.

<a id="function-getMediaViewElement">

### `getMediaViewElement( writer, url, options ) → ViewElement`

For the given media URL string and options, it returns the [view element](module_engine_view_element-ViewElement.md) representing that media.

**Note:** If no URL is specified, an empty view element is returned.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-media-embed/src/mediaregistry.ts#L92)

#### Parameters

* `writer: ViewDowncastWriter`

  The view writer used to produce a view element.

* `url: string`

  The URL to be translated into a view element.

* `options: MediaOptions`

#### Returns

* `ViewElement`

<a id="function-hasMedia">

### `hasMedia( url ) → boolean`

Checks whether the passed URL is representing a certain media type allowed in the editor.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-media-embed/src/mediaregistry.ts#L79)

#### Parameters

* `url: string`

  The URL to be checked

#### Returns

* `boolean`

<a id="function-_getMedia">

### `_getMedia( url ) → Media | null` _(private)_

Returns a `Media` instance for the given URL.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-media-embed/src/mediaregistry.ts#L106)

#### Parameters

* `url: string`

  The URL of the media.

#### Returns

* `Media | null`

  The `Media` instance or `null` when there is none.

<a id="function-_getUrlMatches">

### `_getUrlMatches( url, pattern ) → RegExpMatchArray | null` _(private)_

Tries to match `url` to `pattern`.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-media-embed/src/mediaregistry.ts#L135)

#### Parameters

* `url: string`

  The URL of the media.

* `pattern: RegExp`

  The pattern that should accept the media URL.

#### Returns

* `RegExpMatchArray | null`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
