Saturday, 14 September 2013

Replacement of youtube iframe with its thumbnail

Replacement of youtube iframe with its thumbnail

In this pen there are two post one is with title,image and some text and
second one is having a youtube iframe,title and text.I do not want text to
be appear and I've hide that but the problem is that youtube iframe is
showing but I want its thumbnail not the iframe.
Do some implementations in the following Jquery for youtube thumbnail.
$(function () {
$(".post").each(function () {
var posthead = $(this).find("h2.post-title").text(),
postlink = $(this).find("h2.posttitle a").attr("href");
var imageThumb = $(this).find("img:first"),
imageSrc=imageThumb.attr('src');
$(this).replaceWith("<div class='post'><img class='thumb' src='"
+ imageSrc + "'/><h2 class='hometitle'><a href='" + postlink +
"'>" + posthead + "</a></h2></div>");
});
});

No comments:

Post a Comment