Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8652683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:21:52+00:00 2026-06-12T14:21:52+00:00

I have a jquery code to pull the videos from youtube channel and display

  • 0

I have a jquery code to pull the videos from youtube channel and display as thumbs and play when thumb is clicked..

The problem is that currently the images are naked and I need them to be wrapped in <li> tag so that I create a carousel out of it.

Here is the jquery code

(function() {
    function createPlayer(jqe, video, options) {
        var ifr = $('iframe', jqe);
        if (ifr.length === 0) {
            ifr = $('<iframe width="260" height="146" scrolling="no">');
            ifr.addClass('player');
        }
        var src = 'http://www.youtube.com/embed/' + video.id;
        if (options.playopts) {
            src += '?';
            for (var k in options.playopts) {
                src+= k + '=' + options.playopts[k] + '&';
            }  
            src += '_a=b';
        }
        ifr.attr('src', src);
        jqe.append(ifr);  
    }

    function createCarousel(jqe, videos, options) {
        var car = $('div.youtubecarousel', jqe);
        if (car.length === 0) {
            car = $('<ul>');
            car.addClass('youtubecarousel');
            jqe.append(car);

        }
        $.each(videos, function(i,video) {
            options.thumbnail(car, video, options);
        });
    }

    function createThumbnail(jqe, video, options) {
        var imgurl = video.thumbnails[0].url;
        var img = $('img[src="' + imgurl + '"]');
        if (img.length !== 0) return;
        img = $('<img>');
        img.addClass('thumbnail');
        jqe.append(img);
        img.attr('src', imgurl);
        img.attr('title', video.title);
        img.click(function() {
            options.player(options.maindiv, video, $.extend(true,{},options,{playopts:{autoplay:1}}));
        });

    }

    var defoptions = {
        autoplay: false,
        user: null,
        player: createPlayer,
        carousel: createCarousel,
        thumbnail: createThumbnail,
        loaded: function() {},
        playopts: {
            autoplay: 0,
            egm: 1,
            autohide: 1,
            fs: 1,
            showinfo: 0
        }
    };


    $.fn.extend({
        youTubeChannel: function(options) {
            var md = $(this);
            md.addClass('youtube');
            md.addClass('youtube-channel');
            var allopts = $.extend(true, {}, defoptions, options);
            allopts.maindiv = md;
            $.getJSON('http://gdata.youtube.com/feeds/users/' + allopts.user + '/uploads?alt=json-in-script&format=5&callback=?', null, function(data) {
                var videos = [];
                var feed = data.feed;
                $.each(feed.entry, function(i, entry) {
                    var video = {
                        title: entry.title.$t,
                        id: entry.id.$t.match('[^/]*$'),
                        thumbnails: entry.media$group.media$thumbnail
                    };
                    videos.push(video);
                });
                allopts.player(md, videos[0], allopts);
                allopts.loaded(videos, allopts);
                allopts.allvideos = videos;
                allopts.carousel(md, videos, allopts);


            });
        }
    });

})();

$(function() {
    $('#youtubeplayer').youTubeChannel({user:'autoxtv'});
});

Html code I am using:

<div id="youtubeplayer">
</div>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:21:54+00:00Added an answer on June 12, 2026 at 2:21 pm

    What you ask about can be achieved using jQuery’s .wrap method:

    $('img').wrap('<li />');
    

    You could try adding img.wrap('<li />'); to your createThumbnail function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jQuery code that highlights a link when clicked, and changes the
I have a webpage that uses jquery.load() to pull in html code populated with
I have some jquery code that is doing an ajax lookup and returning comma
i have such problem that jQuery onclick event dont see click on link inside
I have a jQuery tab script that gets content from a PHP file defined
I have a jQuery tabbed search script that gets content from a PHP file
I currently have code which will pull the first element from a database record
I have this jquery code that goes through the nav bar and the selected
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I have jquery validation code which is working fine in ff but the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.