Jump to content

Videos inside processwire: How to embed videos inside processwire?


jester.vergara
 Share

Recommended Posts

Sorry Steve, I'm being a right "end user", you said Pastie and I missed it.

I'll do that for sure, in case it's relevant, I am simply typing into my TinyMCE powered body field these two lines, each is getting a P wrapped around it (by TinyMCE). This is what PW is rendering http://pastie.org/3904883.

Link to comment
Share on other sites

Alan,

Thanks for the update. Yes, your second example won't match using the regex Ryan posted as it is a different format and the regex will need some adjusting to cater for it. In the meantime, can you try this gist as a possible fix for your first example.

Link to comment
Share on other sites

Steve thanks for the _help!_ Ok, good re the 2nd example, at least I am understanding it on a Janet and John level.

Sadly that new regex failed too. I wonder if it's something else :/ (somehow, dunno how tho).

Just tried http://pastie.org/3905012 (/ not \) and Ryan's original and your version and all stubbornly refused to play o_O

Must be me...

Link to comment
Share on other sites

Alan,

Did you see this. I think your first link example is broken anyway. Shouldn't your first example be...

https://www.youtube.com/watch/?v=pbDn_Np3Pfw

...if you want a link to YT that actually works. If that is the case, then could you try my gist again (I just updated it).

You can also try the online regex tester at http://osteele.com/tools/rework/ in cases like this to tweak things.

  • Like 1
Link to comment
Share on other sites

Sorry Steve, I'm being a right "end user", you said Pastie and I missed it.

I'll do that for sure, in case it's relevant, I am simply typing into my TinyMCE powered body field these two lines, each is getting a P wrapped around it (by TinyMCE). This is what PW is rendering http://pastie.org/3904883.

actually both of those are malformed. the second one looks like it also has double encoded & turned to & then turned to & ...

Link to comment
Share on other sites

try to form them like this. (should be outputed like this)

<p>https://www.youtube.com/watch?v=pbDn_Np3Pfw</p>
<p>https://www.youtube.com/watch?v=pbDn_Np3Pfw&feature=player_embedded</p>

then use this script I use on a site:

if(strpos($page->body, '<p>https://www.youtube.com') !== false) {
$replacement = '<iframe width="444" height="280" src="https://www.youtube.com/embed/$1?$2" frameborder="0" allowfullscreen></iframe>';
$page->body = preg_replace('#<p>\s*https://www.youtube.com/watch\?v=([^\s&<]+)([\&amp\;+?].+).*?</p>#iu', $replacement, $page->body);
}

$

with this you can add more than one url params to configure YT player. For example &autoplay=true or something like that etc...

  • Like 1
Link to comment
Share on other sites

Thanks Soma and Steve, I feel so bad for wasting your collective times — it works and as you suspected Steve and spotted Soma it was a bad YT URL I think. The original regex and the URL:

http://www [dot] youtube [dot] com/watch?v=pbDn_Np3Pfw

works. Brilliant, thank you both so much. And I'll experiment with the options Soma, thanks.

I would be dead in the water (well struggling under the upper surface grabbing gasps of air) if it weren't for help from PW-friends like you guys. And on a Sunday... Thanks again :D

Link to comment
Share on other sites

  • 2 weeks later...

Coming in a bit late to the party, but I think I found this on StackOverflow and modified it for my needs - matches most if not all of YT's many URLs:

preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $page->video, $match);

In fact, here's the solution (second post) with all the URLs it matches: http://stackoverflow...sing-preg-match

Matches the following:

https://youtu.be/dQw4w9WgXcQ ...
https://www.youtube.com/embed/dQw4w9WgXcQ ...
https://www.youtube.com/watch?v=dQw4w9WgXcQ ...
https://www.youtube.com/?v=dQw4w9WgXcQ ...
https://www.youtube.com/v/dQw4w9WgXcQ ...
https://www.youtube.com/e/dQw4w9WgXcQ ...
https://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ ...
https://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/dQw4w9WgXcQ ...
https://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ ...
https://www.youtube.com/?feature=player_embedded&v=dQw4w9WgXcQ ...
  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

Has anyone looked at simply employing a tinymce plugin for video? There are quite a few available.

I am currently building out a site with video but am just using the repeater field with a simple textarea to hold the video embed. I have no need to show the video in the body content so have not explored this yet.

Link to comment
Share on other sites

Has anyone looked at simply employing a tinymce plugin for video? There are quite a few available.

You can't simply add plugins to TinyMCE without touching the core yet. Though I did add additional options for third-party plugin, but Ryan still needs to implement this. A pull request is there.

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...