-
-
Notifications
You must be signed in to change notification settings - Fork 213
ce_content :: added save callback to youtube field to extract video id from a url #7514
Conversation
| */ | ||
| public function extractYoutubeId($varValue, DataContainer $dc) | ||
| { | ||
| $url = \Contao\Input::decodeEntities($varValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably set 'decodeEntities'=>true in the eval array instead of manually decoding.
|
+1, nice idea! |
|
This is unfortunately only half way through :( Youtube videos can have a lot of different links formats e.g.
What you're looking for is probably more something like that http://3v4l.org/Tgkt0 |
|
Above give code at http://3v4l.org/Tgkt0 fails to extract youtube code from this URL |
|
Will this PR ever be completed or can I close the ticket? |
http(s)://youtu.be/<video_id> http(s)://www.youtube.com/watch?v=<video_id> http(s)://m.youtube.com/watch?v=<video_id> http(s)://www.youtube.com/embed/<video_id> http(s)://www.youtube.com/v/<video_id>
|
Sorry, I completely forgot about this one :( |
|
I usually use this regex: http://stackoverflow.com/questions/2936467/parse-youtube-video-id-using-preg-match/6382259#6382259 |
|
Implemented in contao/core-bundle@afeef80. The YouTube element now also uses its own template and is embedded via iframe by default. |
Quite a few users struggle with extraction of the video id from a youtube url. Especially with the recently added forced playlist.
This patch adds a save callback to the ce_content.youtube field that extracts the video id from a complete url. The user can just copy and paste whatever the address bar says.