Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/dereuromark/MediaEmbed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Scherer committed Jun 23, 2015
2 parents dd44562 + 31234ae commit 0a97b82
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ It uses iframes if possible, and has a fallback on the embed object if necessary
- Composer

### Note
This is alpha-software. Please feel free to join in and help out to complete it.
Once the coverage is high enough we can release a beta and soon after the first stable.

The plan is to follow SemVar once there is a stable release.
Please feel free to join in and help out to further improve or complete it.
There are always some providers changing their URLs/API or some new ones which are not yet completed.

## Installation

Expand All @@ -38,7 +36,7 @@ create `composer.json`:
```json
{
"require": {
"dereuromark/media-embed": "dev-master"
"dereuromark/media-embed": "0.*"
}
}
```
Expand All @@ -62,7 +60,7 @@ You can then display the HTML code with `getEmbedCode()` or retrieve more inform


## Usage
The simpliest usage, when included via composer autoload, would be:
The simplest usage, when included via composer autoload, would be:
```php
// At the top of the file
use MediaEmbed\MediaEmbed;
Expand All @@ -78,7 +76,7 @@ So if they just paste the URL of the browser, you can directly replace those URL
```php
// Process all links in some content
public function autoLink($text) {
return preg_replace_callback(..., array(&$this, '_linkUrls'), $text);
return preg_replace_callback(..., [&$this, '_linkUrls'], $text);
}

protected function _linkUrls($matches) {
Expand Down Expand Up @@ -108,7 +106,7 @@ Those two values can be stored persistently (the complete URL including schema m

A helper method can then display it:
```php
public function video($host, $id, $options = array()) {
public function video($host, $id, array $options = []) {
if (!isset($this->MediaEmbed)) {
$this->MediaEmbed = new MediaEmbed($options);
}
Expand All @@ -124,15 +122,15 @@ public function video($host, $id, $options = array()) {
This example shows you how to add custom attributes to the iframe tag or parameters to the src url (so you can add the autoplay parameter on youtube for example):
```php
if ($MediaObject = $this->MediaEmbed->parseUrl('http://www.youtube.com/watch?v=111111')) {
$MediaObject->setParam(array(
$MediaObject->setParam([
'autoplay' => 1,
'loop' => 1
));
$MediaObject->setAttribute(array(
]);
$MediaObject->setAttribute([
'type' => null,
'class' => 'iframe-class',
'data-html5-parameter' => true
));
]);

return $MediaObject->getEmbedCode();
}
Expand All @@ -151,7 +149,7 @@ This should return and embed code like:
* @return string
*/
protected function _parseVideo($string) {
return preg_replace_callback('/\[video=?(.*?)\](.*?)\[\/video\]/is', array($this, '_processVideo'), $string);
return preg_replace_callback('/\[video=?(.*?)\](.*?)\[\/video\]/is', [$this, '_processVideo'], $string);
}

/**
Expand Down Expand Up @@ -191,7 +189,7 @@ So `[video]http://www.youtube.com/v/123[/video]` becomes `[video=youtube]123[/vi
* @return string
*/
public function prepareForOutput($string) {
return preg_replace_callback('/\[video=?(.*?)\](.*?)\[\/video\]/is', array($this, '_finalizeVideo'), $string);
return preg_replace_callback('/\[video=?(.*?)\](.*?)\[\/video\]/is', [$this, '_finalizeVideo'], $string);
}

/**
Expand Down

0 comments on commit 0a97b82

Please sign in to comment.