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] My code is not getting embeded

15 Posts
5 Users
3 Reactions
4,397 Views
Posts: 27
Topic starter
(@mrfahadkhan)
Eminent Member
Joined: 6 years ago

Hi, i am trying to embed a youtube video via code, it show me the video preview in editor but when i post it it shows nothing.

14 Replies
Sofy
Posts: 5483
 Sofy
Admin
(@sofy)
Support Team
Joined: 8 years ago

Hi @mrfahadkhan,

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 advanced embedding options please check out wpForo Embeds add-on:

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

2 Replies
(@mrfahadkhan)
Joined: 6 years ago

Eminent Member
Posts: 27

I have added this code at the bottom of Functions.php but still my videos are not getting embedded.

Moderator
(@martin)
Joined: 9 years ago

Support Team
Posts: 990

Please click on the [Delete all caches] button in wpForo cache in Dashboard > Forums > Dashboard admin page. Then delete website cache, then navigate to forum home page and press Ctrl+F5. If it doesn't help, leave some example URL, where we can check it.

Posts: 27
Topic starter
(@mrfahadkhan)
Eminent Member
Joined: 6 years ago
1 Reply
Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10616

@mrfahadkhan, please leave example of your embed URL not the post URL. What have you embedded in this page?

Posts: 27
Topic starter
(@mrfahadkhan)
Eminent Member
Joined: 6 years ago

<iframe width="560" height="315" src="https://www.youtube.com/embed/WddvCQ6Bk0o" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Sofy
Posts: 5483
 Sofy
Admin
(@sofy)
Support Team
Joined: 8 years ago

Hi @mrfahadkhan,

You just need to insert the URL without iframe tag, only the < https://www.youtube.com/embed/WddvCQ6Bk0o > part. 

By default, wpForo doesn't allow to use iframe tag, as it is not secure. There can be a lot of spam post.

In Dashboard > Forums > Tools > "Allow extra HTML tags" textarea you should add iframe tag name with its attributes . This will allow using iframe tag  (use the source ( {:} )  button before passing the link).

iframe
Page 1 / 2