Notifications
Clear all

[Solved] Original WP embed function for YouTube?

38 Posts
18 Users
8 Likes
17.9 K Views
Alias79
Posts: 33
Topic starter
(@alias79)
Eminent Member
Joined: 6 years ago

Currently, Wordpress automatically embeds YouTube videos. I read you work in an addon for embeds multitude of services, something very interesting. But, on the other hand, you could not enable the original WP embed function for YouTube?

I want to start to migrate to WP Foro, but without YouTube is difficult. To start (to start...) I not need a media player, or insert other services, but YouTube is basic in a forum, and the embed of WordPress works great.

Thanks! 🙂

Topic Tags
37 Replies
shashank
Posts: 16
(@shashank)
Active Member
Joined: 6 years ago

seems like we have a solution. 

Can you guys share what exactly does this modification do? Does it work all across wp-foro?

Reply
Robert
Posts: 9261
Admin
(@robert)
Support Team
Joined: 6 years ago

Just put this code in active WordPress theme's functions.php:

add_filter('wpforo_content_after', 'wpforo_custom_video_embed', 10);
function wpforo_custom_video_embed( $content ){
$paterns = array();
$paterns[] = "/<a[^><]+>\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
$paterns[] = "/<a[^><]+>\s*[a-zA-Z\/\/:\.]*youtu.be\/([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
$content = preg_replace($paterns, "<iframe width=\"420\" height=\"280\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>", $content);
return $content;
}

For more embedding options I recommend wpForo Embeds addon:

https://gvectors.com/product/wpforo-embeds/

Reply
3 Replies
fireheadman
(@fireheadman)
Joined: 4 years ago

New Member
Posts: 1

This method no longer seems to work still works with wpforo v1.5.1

I was previously using this hack to embed youtube, now it has stopped working for me....

UPDATE:  found my issue:

https://www.youtube.com/watch?v=EJkWirlcLaA .   <-- Works

https://www.youtube.com/watch?time_continue=21&v=EJkWirlcLaA .   <-- Does not work, stripped out "time_continue=21&"  and its working now, so clearing just a formatting issue.

Reply
Mostroty
(@mostroty)
Joined: 2 years ago

New Member
Posts: 1

Hello @robert, nice the code that you gave us but, how can i do the same with Loom.com? Im trying to do the same that you explained with youtube but with loom.

Reply
Robert
Admin
(@robert)
Joined: 6 years ago

Support Team
Posts: 9261

@mostroty,

I'm sorry but I have no solution for this video hosting. I'd recommend check out the wpForo Embeds addon. As far as I see it supports Loom: https://gvectors.com/product/wpforo-embeds/

Reply
Griffsy
Posts: 13
(@griffsy)
Active Member
Joined: 6 years ago

All working now 🙂 thanks to all. Used your instructions Robert 🙂

Reply
redmars
Posts: 2
(@redmars)
New Member
Joined: 6 years ago

I have two questions about the code that was added in Step 1. 

I'm getting <Va> after the insert of the video.  Re-checked my files and found no typos.

Second part is what if the user is posting with the short URL from YouTube

https ://youtu.be/SSSSSSS

 

Reply
Page 1 / 5
Share: