Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

ce_content :: added save callback to youtube field to extract video id from a url #7514

Closed
wants to merge 5 commits into from

Conversation

uvoelkel
Copy link

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.

@leofeyer leofeyer added this to the 3.5.0 milestone Dec 11, 2014
*/
public function extractYoutubeId($varValue, DataContainer $dc)
{
$url = \Contao\Input::decodeEntities($varValue);
Copy link
Member

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.

@aschempp
Copy link
Member

+1, nice idea!

@Toflar
Copy link
Member

Toflar commented Dec 11, 2014

This is unfortunately only half way through :( Youtube videos can have a lot of different links formats e.g.

  • http://www.youtube.com/watch?v=<video_id>
  • http://youtu.be/<video_id>
  • http://www.youtube.com/v/<video_id>
  • https://m.youtube.com/watch?v=<video_id>
  • etc.

What you're looking for is probably more something like that http://3v4l.org/Tgkt0

@tsarma
Copy link

tsarma commented Dec 12, 2014

Above give code at http://3v4l.org/Tgkt0 fails to extract youtube code from this URL
https://www.youtube.com/watch?v=b4a-qZeOBXc

@leofeyer leofeyer modified the milestones: 3.x.x, 3.5.0 Mar 27, 2015
@leofeyer
Copy link
Member

leofeyer commented May 3, 2015

Will this PR ever be completed or can I close the ticket?

@uvoelkel
Copy link
Author

Sorry, I completely forgot about this one :(
Any other format I am missing?

@leofeyer leofeyer modified the milestones: 4.2.0, 3.x.x Nov 19, 2015
@fritzmg
Copy link
Contributor

fritzmg commented Dec 3, 2015

@leofeyer leofeyer closed this Mar 21, 2016
@leofeyer leofeyer reopened this Mar 21, 2016
@leofeyer leofeyer self-assigned this Apr 8, 2016
leofeyer added a commit to contao/core-bundle that referenced this pull request Apr 8, 2016
leofeyer added a commit to contao/core-bundle that referenced this pull request Apr 8, 2016
@leofeyer
Copy link
Member

leofeyer commented Apr 8, 2016

Implemented in contao/core-bundle@afeef80. The YouTube element now also uses its own template and is embedded via iframe by default.

@leofeyer leofeyer closed this Apr 8, 2016
@leofeyer leofeyer mentioned this pull request Apr 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants