diff --git a/src/Items/Video.php b/src/Items/Video.php index 3e242177e76023e07cde2ef70b9f8eb0a315b7d9..6f0d22066781ecd81ff9976db2fb86492580533d 100644 --- a/src/Items/Video.php +++ b/src/Items/Video.php @@ -12,7 +12,13 @@ class Video implements Item public function getWidget() { - preg_match('/^https:\/\/www\.youtube\.com\/watch\?v=([A-Za-z0-9\-\_]*)&?.*/', $this->url, $matches); - return '<iframe width="100%" height="400" src="//www.youtube.com/embed/' . $matches[1] . '" frameborder="0" allowfullscreen></iframe>';; + return '<iframe width="100%" height="400" src="//www.youtube.com/embed/' . $this->getId() . '" frameborder="0" allowfullscreen></iframe>';; + } + + public function getId() + { + preg_match('/^https:\/\/www\.youtube\.com\/watch\?v=(.*)/', $this->url, $matches); + + return $matches[1]; } } \ No newline at end of file