AI Assistant
Notifications
Clear all

[Solved] Original WP embed function for YouTube?

38 Posts
18 Users
8 Reactions
30.9 K Views
Posts: 35
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@alias79)
Trusted Member
Joined: 10 years ago
[#323]

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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@shashank)
Eminent Member
Joined: 10 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: 10719
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@robert)
Support Team
Joined: 2 months 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: 8 years ago

New Member
Posts: 1
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

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: 2 months ago

Support Team
Posts: 10719
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@griffsy)
Eminent Member
Joined: 10 years ago

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


redmars
Posts: 2
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@redmars)
New Member
Joined: 10 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
Share: