PDA

View Full Version : Some BB code that you may or may not find useful



Sigma
02-07-2012, 12:11 AM
This is for Invision Power Board, but it should easily translate over to vBulletin with a few tweaks. This code parses links so people don't need to manually use BB code at all.

YouTube: -

Media replacement match: -


http://(www.)?youtube.com/watch\?v=([\d\w-_]+?)(&\S+?)?

Code: -


<object style="height: 390px; width: 640px"><param name="movie" value="http://youtube.com/v/$2?version=3" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed src="http://youtube.com/v/$2?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></embed></object>

YouTu.be (for when people use the "Share" links): -

Media replacement match: -


http://(www.)?youtu.be/([\d\w-_]+?)$

Code: -


<object width="640" height="390"><param name="movie" value="http://youtube.com/v/$2"></param><param name="wmode" value="transparent"></param><param name="flashvars" value="fs=1&autoplay=0&playerMode=embedded"></param><embed src="http://youtube.com/v/$2" type="application/x-shockwave-flash" wmode="transparent" width="640" height="390"></embed></object>

Mixcloud: -

Media replacement match: -


http://www.mixcloud.com/{1}/{2}/

Code: -


<div> <object width="300" height="300">
<param name="movie" value="http://www.mixcloud.com/media/swf/player/mixcloudLoader.swf"></param>
<param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param>
<param name="flashVars" value="feed=http://www.mixcloud.com/$1/$2/?for_player=1"></param>
<embed src="http://www.mixcloud.com/media/swf/player/mixcloudLoader.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" flashvars="feed=http://www.mixcloud.com/$1/$2/?for_player=1" width="300" height="300"></embed></object>
<div style="clear:both; height:3px;"></div> <p style="display:block; font-size:12px; font-family:Helvetica, Arial, sans-serif; margin:0; padding: 3px 4px 3px 4px; color:#999;">
<a href="http://www.mixcloud.com/$1/$2/?utm_source=widget&amp;utm_medium=web&amp;utm_campaign=bas e_links&amp;utm_term=cloudcast_link" style="color:#02a0c7; font-weight:bold;">Click here</a> to see it on Mixcloud</p>
<div style="clear:both; height:3px;"></div> </div>

SoundCloud: -

Media replacement match: -


http://soundcloud.com/{1}/{2}

Code: -


<object height="81" width="100%"> <param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2F$1%2F $2"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2F$1%2F $2" type="application/x-shockwave-flash" width="100%"></embed> </object> <span><a href="http://soundcloud.com/$1/$2">Listen on SoundCloud.com</a></span>

Sol
02-07-2012, 12:17 AM
you're speaking geek. :P

I need to learn geek. Insteresting sounding language.

Sigma
02-07-2012, 12:25 AM
Haha, well I noticed that members still need to manually type code to embed something here. If you can somehow implement the above, then just posting a YouTube, SoundCloud or Mixcloud link will automatically turn it into an embedded player, with a link underneath to the file.

swine
02-07-2012, 01:42 AM
Cool, so the whole point is that you make a script and set the variables to 1 & 2 (for soundcloud for instance) and then have the script put the 1 & 2 parts into the code where indicated?

Just learning how to speak geek

Sigma
02-07-2012, 01:55 AM
Yeah, well that's how it works in the forum software I use. You can set how the software parses certain links, so in this case, when it detects links from particular sites it'll automatically embed them with a player of a certain type and size, and it also includes a link underneath the embedded player. For regular forum users, it means you can just copy and paste a SoundCloud/Mixcloud/YouTube link into a post instead of having to manually type out BB code.

swine
02-07-2012, 02:14 AM
Interesting, first I've heard of this. So from a quick google search, I as a regular forum user could install something like pbpBB and set that to parse those links?

Sigma
02-07-2012, 02:19 AM
Yeah man, you should be able to do this in any of the more popular forum software options.

I like Invision Power Board cos it allows you to install plug-ins, kinda like extensions for a web browser. If one doesn't work or you don't like it, you can just bin it, but amongst other things it allows you to easily install the code required to automatically parse links for popular file hosting sites. You can also import code via XML.

swine
02-07-2012, 02:30 AM
Thanks for explaining that, Ill check it out.

Sigma
02-07-2012, 02:33 AM
No probs.

I would highly recommend Invision Power Board BTW. I don't know how it compares in terms of pricing compared to the others, but in terms of features/functionality it's the best I've used.

swine
02-07-2012, 02:40 AM
Yeah Im searching through them now and trying to really understand whats going on. Ill probably check out the phpbb or something of the sort first since its free then I can understand what Id want to pay for

edit: listening to your dnb mix from 2004. pretty yummy. im following you on soundcloud now as "WillCool"

Stripe
02-07-2012, 03:40 PM
the one I item that I see can perhaps be an issue with some of the above is if someone wants to try to post a link to their SC or MC page. The plugin would try to automatically associate it to the player.

Sigma
02-07-2012, 04:44 PM
With that particular code, it only embeds a player if you are linking to a track/mix, so this would embed automatically: -

http://soundcloud.com/deejaysigma/sigma-80s-funk-mix

But this wouldn't: -

http://soundcloud.com/deejaysigma

On my site, when someone posts a link to a SoundCloud/Mixcloud mix or track, they almost always want it to be embedded as a player in the post, so it made sense to have it done automatically. The user can use URL tags to wrap the link if they just want a straight link without the player.

Stripe
02-07-2012, 05:03 PM
gotcha, will keep looking into :)

Claude Perdu
02-07-2012, 05:17 PM
Another forum I'm on does this, makes things way easier tbf.

One thing though: put a limit on amount of embeds/post because if everyone's gonna dump 5 flash objects per post the browsing experience becomes horrid.