joe1992w/laravel-media-embed

Laravel Wrapper for dereuromark/MediaEmbed to generate embed HTML for popular media hosts

v1.0.1 2017-03-05 14:18 UTC

This package is not auto-updated.

Last update: 2025-01-19 03:28:54 UTC


README

A simple wrapper for dereuromark/MediaEmbed to generate embed HTML for popular media hosting services.

Installation

composer require joe1992w/laravel-media-embed

OR

"require": {
    "joe1992w/laravel-media-embed": "^1.0",
},
composer install

Service Provider

'providers' => [
    // Others...
    Joe1992w\LaravelMediaEmbed\Providers\LaravelMediaEmbedServiceProvider::class,
],

Facade

'aliases' => [
    // Others...
    'LaravelMediaEmbed' => Joe1992w\LaravelMediaEmbed\Facades\LaravelMediaEmbed::class,
],

Usage

//URL to be used for embed generation
$url = "https://www.youtube.com/watch?v=8eK-5ivYb3o";

//Optional array of website names, if present any websites not in the array will result in false being returned by the parser
$whitelist = ['YouTube', 'Vimeo'];

//Optional parameters to be appended to embed
$params = [
    'autoplay' => 1,
    'loop' => 1
  ];

//Optional attributes for embed container
$attributes = [
  'type' => null,
  'class' => 'iframe-class',
  'data-html5-parameter' => true
];

return LaravelMediaEmbed::parse($url, $whitelist);
// "<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent" type="text/html" width="480" height="295" frameborder="0" allowfullscreen></iframe>"

return LaravelMediaEmbed::parse($url);
// "<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent" type="text/html" width="480" height="295" frameborder="0" allowfullscreen></iframe>"

return LaravelMediaEmbed::parse($url, ['Vimeo']);
// false

return LaravelMediaEmbed::parse($url, $whitelist, $params, $attributes)
//<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent&amp;autoplay=1&amp;loop=1" type="" width="480" height="295" frameborder="0" allowfullscreen class="iframe-class" data-html5-parameter></iframe>

Supported Hosts

Please see dereuromark/MediaEmbed

Supported Website Whitelist names