Media Embed
The media embed feature adds support for easily inserting embeddable media, such as YouTube or Vimeo videos and tweets, into your rich text content.
Alternatively, you can directly paste the media URL into the editor content, and it will be automatically embedded for you.
Configuration:
To configure the media embed feature, you have the option to override providers
or add extraProviders
through the configuration file.
<?php
return [
...
'toolbar' => [
...
'options' => [
...
'mediaEmbed' => [
'providers' => [
[
'name' => 'youtube',
'url' => [
'/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/',
'/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/',
'/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/',
'/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/'
],
'html' => '
<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: calc(56.2493% + 26px);">
<div><b>id</b>: ${match[1]}, <b>start</b>: ${match[2]}</div>
<iframe
src="https://www.youtube.com/embed/${match[1]}${match[2] ? `?start=${match[2]}` : ""}"
style="position: absolute; width: 100%; height: calc(100% - 26px); top: 26px; left: 0;"
frameborder="0"
allow="autoplay; encrypted-media"
allowfullscreen
/>
</div>'
]
],
// or
'extraProviders' => [
[
'name' => 'example',
'url' => '/^example\.com\/media\/(\w+)\/(.+)/',
'html' => '<p>first: ${match[1]}</p><p>second: ${match[2]}</p>'
]
]
],
]
],
];
Last updated