Problem in getting the img src from jyoutube plugin
Hi,
I am using datalist to get the youtube url from the database and . I am using jquery "jyoutube plugin" to get the thumbnail of the Youtube URL. The jyoutube plugin takes the youtube url and returns the thumnail src. i am not able to call the javascript function in the img src attribute so kept an blank image on the img src and then on the onload event i called the javascript to set the src to the thumnail src returned by the jquery. It works fine in Firefox but IE gives me error as
"Stack overflow at line 1"
Any clue about the error in my code..I know its not a good idea to use img onload event. Is there any way i can call this javascript function from img src attribute?
aspx page:
<table>
<tr>
<td class="gallery clearfix">
<a href='<%# DataBinder.Eval(Container.DataItem,"VideoURL")%>' rel="prettyPhoto[play]" title='<%# DataBinder.Eval(Container.DataItem,"VideoTitle")%>' >
<img src="images/blankimage.PNG" onload="GetThumbnail(this,'<%# DataBinder.Eval(Container.DataItem,"VideoURL")%>')"
alt='<%# DataBinder.Eval(Container.DataItem,"ThumbnailTitle") %>' width="200" />
</a>
</td>
<td>
<asp:Label ID="Label1" runat="server" Text="Label"> <%# DataBinder.Eval(Container.DataItem, "VideoTitle")%></asp:Label>
</td>
</tr>
</table>
Javascript:
function GetThumbnail(img, URL)
{
var imageSrc = URL;
if(img.src != imageSrc)
{
// don't get stuck in an endless loop
img.src = $.jYoutube(imageSrc, 'small') ;
}
else
{
return false;
}
}
(function($){
$.extend({
jYoutube: function( url, size ){
if(url === null){ return ""; }
size = (size === null) ? "big" : size;
var vid;
var results;
results = url.match("[\\?&]v=([^&#]*)");
vid = ( results === null ) ? url : results[1];
if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg";
}else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg";
}
}
})
})(jQuery);