Notifications
Clear all

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

[Solved] Original WP embed function for YouTube?

38 Posts
18 Users
8 Reactions
24.7 K Views
Posts: 35
Topic starter
(@alias79)
Trusted Member
Joined: 9 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! 🙂

37 Replies
Posts: 16
(@shashank)
Eminent Member
Joined: 9 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?

Robert
Posts: 10616
Admin
(@robert)
Support Team
Joined: 9 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/

3 Replies
(@fireheadman)
Joined: 7 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.

(@mostroty)
Joined: 5 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.

Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10616

@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/

Griffsy
Posts: 13
(@griffsy)
Eminent Member
Joined: 9 years ago

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

redmars
Posts: 2
(@redmars)
New Member
Joined: 9 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

 

Page 1 / 5