Joined: Mar 2009 Gender: Male Posts: 2,594 Location: MI, USA Karma: 102
YouTube Thumbnail Links in Posts « Thread Started on Aug 13, 2011, 3:42am »
YouTube Thumbnail Links in Posts by SubDevo Tested in IE, FF, Opera, Safari and Chrome.
This code will convert posted YouTube video URL text links into a clickable thumbnail image link. The actual thumbnail image for the video is automatically added. Clicking the image will play the video in a popup window. If you want to watch the video on YouTube, click the small "YouTube" logo image. This is what you will see when you post a YouTube video URL text link...
You have a choice of the default background image (shown above), a "black" version or create your own! They can be found at the bottom of this post with instructions for adding your own custom background.
"Hey! Isn't this against PB TOS?"
Not at all. This code is simply converting the YouTube video text link into an image link. No custom UBBC is needed or used. It does not block, remove, change or move any PB ads or modify an embedded video that has been added with the YouTube UBBC. It does not convert any links that the user has already made into an image or is using custom text for the link.
Enjoy!!! SubDevo
More info: The image is added inline. That means you can put them right next to each other in the same row. If the code is removed, all YouTube links go back to normal text links. The code also has a CSS section. Be careful when changing any of the values in it. I took great care to make sure it looks exactly the same in all the browsers I tested this code in. If you wish to use your own images, read the "Advanced" section below the code posts.
Variables: There is only one...
var ytLogo="http://i53.tinypic.com/2h4jkzk.png"; // Logo Image URL Enter the URL to your own logo image. This will be the link to watch on YouTube.
<script type="text/javascript"> /* YouTube Thumbnail Links in Posts by SubDevo */ /* Global Footer - Please leave this header intact. Do not repost. */ /* [url]http://interoceandesigns.com[/url] or [url]http://lsdp.proboards.com[/url] */
var ytLogo="http://i53.tinypic.com/2h4jkzk.png"; // Logo Image URL
Some of you may want a larger thumbnail. This is about 33% larger. Be aware that the image is resized on the fly and the quality of the resized image is dependent upon the browser and version the user is viewing with. IE7 has the worst resize algorithm and it doesn't look that great. Just something to keep in mind. Use this image as the logo image in var ytLogo in the code: http://i55.tinypic.com/2mp0t3p.png
You may use your own image for the background of the thumbnail and also for the logo. The background URL is put into the CSS. The Logo image URL goes into the script (code).
.yt_container
This affects the entire thumbnail. The background image goes here and also the height and width of the image used. Putting a border statement here will surround the entire thumbnail.
.yt_thumb
This affects the actual YouTube thumbnail image. Use higher values for "top" to move it down. Keep the height set to 90 for the default YouTube thumbnail image size. Anything larger than 90 will stretch the image and the quality of it will lessen. Changing border from "0" will put a border around the actual YouTube thumbnail.
.yt_logo
This affects the small logo image that you set in the code. Use higher values for "top" to move it down. Use higher values for "right" to move it to the LEFT. Changing border from "0" will put a border around the logo image.
Joined: Nov 2010 Gender: Male Posts: 976 Location: California Karma: 53
Re: YouTube Thumbnail Links in Posts « Reply #7 on Aug 14, 2011, 5:44am »
Awesome code bro! This looks very cool!
Umm, I know you said not to do this, but I would like to change the sizes of the thumbnails to 200px width, and 190px height. I tried doing it on my own, but it's too confusing. Could you help me out?
Also, I just noticed that the code wont work if you try to use other bb codes with it. I tried centering it, and when I did, it showed me the link rather than the thumbnail. Would you be able to fix this?
Ok so after trial and error, I figured out that for you to be able to use bb with this, you would need to leave a space between the link and the bb tag, like so:
Joined: Mar 2009 Gender: Male Posts: 2,594 Location: MI, USA Karma: 102
Re: YouTube Thumbnail Links in Posts « Reply #8 on Aug 14, 2011, 7:50am »
Hey everybody! Grab the code again if you are using it. I made a small change since I noticed that IE didn't put a space between the videos and also some "old" thumbnails are a bit larger than the rest and it pushed the small YouTube logo down too far. Both have been fixed. I would not have noticed these if it weren't for Speed Demon's test post.
It's not the code that doesn't work without a space, it is the way PB parses for URLs in a post. PB won't convert it to a link unless there is a space before http: (even without this code) unless it is at the beginning of a line. This includes a link in a sentence (without UBBC).
This will be a link http://www.google.com/ No link here because no space beforehttp://www.google.com/ So with UBBC, you need to just put a space before, after is not necessary.
I guessed it. I KNEW you would be the first to ask to make it bigger! I just KNEW IT!
I enlarged the background image and the small YouTube log that I'm currently using. It isn't as nice as it could be... And we'll have to resize the thumbnail image on the fly. Which looks like crap in IE7! Hopefully IE8 is better and other browsers should look "acceptable". IE has the worst resize algorithm. This is the reason for the size that I decided upon. Give this a shot. I might add this to the original post for a larger option or maybe just leave it here. I'm not happy with it...
Joined: Nov 2010 Gender: Male Posts: 976 Location: California Karma: 53
Re: YouTube Thumbnail Links in Posts « Reply #9 on Aug 14, 2011, 11:30am »
Haha! You're starting to know me Sub.
I changed the background, and I think it looks pretty good: Clicky
I looked at all browsers (except Opera), and they look the same too.
The only thing though, I would like to know if you could move the Youtube log, a bit to the left and a bit lower? I want it to be in the middle of the text.
I would change the top value first in .youtube_thumb img to about 18px to get the thumbnail with even black borders around it. Then position the logo. But, if you move it, you will have to redo your background image because it will cover up xtreme elites.
Hey everybody! Grab the code again if you are using it. I made a small change since I noticed that IE didn't put a space between the videos and also some "old" thumbnails are a bit larger than the rest and it pushed the small YouTube logo down too far. Both have been fixed. I would not have noticed these if it weren't for Speed Demon's test post.
I was going to ask you about that, good catch and fix, works perfect.
Ok so I added the class, but it doesn't seem to move the logo when I change the values. No matter what I put in.
GAAHH! I forgot the dot . before the class name! But that isn't the only issue. It needed higher specificity. Grag the CSS again from my previous post.
Speed, It wouldn't have been fixed as fast, if you hadn't had that test post. The "no space" only happens in IE. And it would have been a long time till someone brought up the positioning issue since those larger thumbnail sizes are rare (older videos).
Speed, It wouldn't have been fixed as fast, if you hadn't had that test post. The "no space" only happens in IE. And it would have been a long time till someone brought up the positioning issue since those larger thumbnail sizes are rare (older videos).