From 41c82730ae506d078a0926b2a4c4e3cf575405d4 Mon Sep 17 00:00:00 2001 From: Maxime Veber <nek.dev@gmail.com> Date: Fri, 10 Nov 2017 11:28:53 +0100 Subject: [PATCH] Improve video item --- src/Items/Video.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Items/Video.php b/src/Items/Video.php index 3e24217..6f0d220 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 -- GitLab