Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Multiquote (on) Multiquote (off)
Add Reply
Embed Videos Without BBCode
Topic Started: Jul 24 2012, 06:06 PM (16,240 Views)
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code name: Embed Videos Without BBCode

Date created: Jul 24 2012

Author(s): Cory

Description: This code will allow you to link to a video from a specified site in a post and it will automatically be embedded.

Preview: Preview #1 - Preview #2

Admin CP Posted Image Themes Posted Image Board Template Posted Image Below the Board

YouTube:
Code:
 
<script type="text/javascript">
//<![CDATA[
$('a[rel]:contains(youtube.com)').each(function () {
var href = this.href = this.href.replace('watch?', '').replace('=', '/');
$(this).replaceWith('<object width="250" height="250" data="' + href + '" type="application/x-shockwave-flash"><param value="never" name="AllowScriptAccess"><param value="transparent" name="wmode"><param value="' + href + '" name="movie"><param value="true" name="play"><param value="true" name="loop"><param value="high" name="quality"></object>');
});
//]]>
</script>
youtu.be:
Code:
 
<script type="text/javascript">
//<![CDATA[
$('a[rel]:contains(youtu.be)').each(function () {
var href = this.href = this.href.replace('.be/', 'be.com/v/');
$(this).replaceWith('<object width="250" height="250" data="' + href + '" type="application/x-shockwave-flash"><param value="never" name="AllowScriptAccess"><param value="transparent" name="wmode"><param value="' + href + '" name="movie"><param value="true" name="play"><param value="true" name="loop"><param value="high" name="quality"></object>');
});
//]]>
</script>
Vimeo:
Code:
 
<script type="text/javascript">
//<![CDATA[
$('a[rel]:contains(vimeo.com)').each(function () {
var id = this.href.split('/')[3];
$(this).replaceWith('<iframe src="http://player.vimeo.com/video/' + id + '" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>');
});
//]]>
</script>
Dailymotion:
Code:
 
<script type="text/javascript">
//<![CDATA[
$('a[rel]:contains(dailymotion.com)').each(function () {
var href = this.href = this.href.split('_')[0].replace('/video/', '/embed/video/');
$(this).replaceWith('<iframe frameborder="0" width="480" height="270" src="' + href + '"></iframe>');
});
//]]>
</script>
Meta Cafe:
Code:
 
<script type="text/javascript">
//<![CDATA[
$('a[rel]:contains(metacafe.com)').each(function () {
var id = this.href.split('/watch/')[1].split('/')[0];
$(this).replaceWith('<iframe src="http://www.metacafe.com/embed/' + id + '/" width="440" height="248" allowFullScreen frameborder="0"></iframe>');
});
//]]>
</script>
Edited by Cory, Jul 9 2013, 05:51 AM.
Online Profile Quote Post Goto Top
 
Geoffrey
Member Avatar
Devilishly Handsome
[ *  *  *  *  * ]
Very nice. Would there be a way to stop the code from working on a certain link, like if one was to post a link that they didn't want embedded?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
To link to a YouTube video use the youtu.be link from the sharing options.
Online Profile Quote Post Goto Top
 
ehll
Member
[ * ]
works fine, except for the shoutbox area it does the same.
even when Links are disabled on shoutbox from the admin CP.

could you make it so that it excludes the shoutbox?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code:
 
<script type="text/javascript">
$('#sbx a[rel]').addClass('shoutlink');

$('a[rel]:contains(youtube.com):not(a.shoutlink)').each(function () {
this.href = this.href.replace('watch?', '').replace('=', '/');
var href = $(this).attr('href');
$(this).replaceWith('<object width="250" height="250" data="' + href + '" type="application/x-shockwave-flash"><param value="never" name="AllowScriptAccess"><param value="transparent" name="wmode"><param value="' + href + '" name="movie"><param value="true" name="play"><param value="true" name="loop"><param value="high" name="quality"></object>');
});
</script>
Use that instead to exclude it from the shoutbox.
Online Profile Quote Post Goto Top
 
HolySexy
Member
[ * ]
Embed YouTube Videos Without BBCode you got the codes? i can't see i want it please
see the photo http://i47.tinypic.com/2s6qc7a.jpg
Edited by HolySexy, Nov 19 2012, 06:24 PM.
Offline Profile Quote Post Goto Top
 
alan131210
Member
[ *  * ]
where do you put this?? below the board ?
Offline Profile Quote Post Goto Top
 
tankbeta
Member
[ * ]
how about vimeo videos? will it also embedd automatically?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code:
 
<script type="text/javascript">
//<![CDATA[
$('a[rel]:contains(vimeo.com)').each(function () {
var id = this.href.split('/')[3];
$(this).replaceWith('<iframe src="http://player.vimeo.com/video/' + id + '" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>');
});
//]]>
</script>
Use that for Vimeo.
Online Profile Quote Post Goto Top
 
alan131210
Member
[ *  * ]
what ab out for FB videos !!? :)
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code:
 
<script type="text/javascript">
//<![CDATA[
$('a[rel]:contains(facebook.com/video/)').each(function () {
var href = this.href;
$(this).replaceWith('<iframe src="' + href + '" width="500" height="300" frameborder="0"></iframe>');
});
//]]>
</script>
Online Profile Quote Post Goto Top
 
alan131210
Member
[ *  * ]
^^ just installed it didnt work!

the link to video posted
Link
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Can you post what the 'Embed Video' link gives you?
Online Profile Quote Post Goto Top
 
alan131210
Member
[ *  * ]
<iframe src="http://www.facebook.com/video/embed?video_id=579107385463530" width="360" height="240" frameborder="0"></iframe>

this come up, take a look!
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
http://www.facebook.com/video/embed?video_id=579107385463530

That's the link you should be using.
Online Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply