zoon / commonmark-ext-youtube-iframe
Extension for league/commonmark to replace youtube link with iframe
Installs: 235 594
Dependents: 1
Suggesters: 0
Security: 0
Stars: 12
Watchers: 4
Forks: 5
Open Issues: 0
Type:commonmark-extension
Requires
- php: ^7.4 || ^8.0
- league/commonmark: ^2.2
Requires (Dev)
- phpunit/phpunit: ^7.0 || ^8.0 || ^9.0
README
Extension for league/commonmark to replace youtube link with iframe.
Install
composer require zoon/commonmark-ext-youtube-iframe
Test
./vendor/bin/phpunit
Example
use League\CommonMark\CommonMarkConverter; use Zoon\CommonMark\Ext\YouTubeIframe\YouTubeIframeExtension; $converter = new CommonMarkConverter([ 'youtube_iframe' => [ 'width' => '600', 'height' => '300', 'allow_full_screen' => true, ], ]); $converter->getEnvironment()->addExtension(new YouTubeIframeExtension()); echo $converter->convert('Check this: [](https://youtu.be/mVnSpPMgoWM?t=10)')->getContent(); echo $converter->convert('Check this: [](https://www.youtube.com/watch?v=mVnSpPMgoWM&t=10)')->getContent();
<p>Check this: <iframe width="600" height="300" src="https://www.youtube.com/embed/mVnSpPMgoWM?start=10" frameborder="0" allowfullscreen="1"></iframe></p> <p>Check this: <iframe width="600" height="300" src="https://www.youtube.com/embed/mVnSpPMgoWM?start=10" frameborder="0" allowfullscreen="1"></iframe></p>