嵌入来自流行提供商的媒体内容。

dev-master 2017-06-03 14:33 UTC

This package is not auto-updated.

Last update: 2024-09-27 23:03:36 UTC


README

根据URL生成媒体HTML(YouTube、Vimeo、Kickstarter等)。

原始包:https://github.com/KaneCohen/embed

安装

将以下require添加到您的composer.json文件中

Laravel 5*版本

    "davodavodavo3/media": "dev-master"
    // or
    "davodavodavo3/media": "5.4.*@dev",

然后运行composer installcomposer update来下载并自动加载。

或者简单运行

composer require "davodavodavo3/media":"5.4.*@dev"

然后在您的config/app.php中添加

'providers' => array(

	//...
	Scorpion\LaravelMedia\MediaServiceProvider::class,
	//...

)

在别名中

'aliases' => array(

	//...
	'Media' => Scorpion\LaravelMedia\Facades\Media::class,
	//...

)

用法

$media = Media::make('http://youtu.be/uifYHNyH-jA')->parseUrl()
// Will return Media class if provider is found. Otherwie will return false - not found. No fancy errors for now.
if ($media) {
	// Set width of the media embed.
	$media->setAttribute(['width' => 600]);

	// Print html: '<iframe width="600" height="338" src="//www.youtube.com/embed/uifYHNyH-jA" frameborder="0" allowfullscreen></iframe>'.
	// Height will be set automatically based on provider width/height ratio.
	// Height could be set explicitly via setAttr() method.
	echo $media->getHtml();
}