Jump to content

YouTube thumbnails to a grid


biggieuk

Recommended Posts

Hi,

 

Not too sure if this is the correct forum for this as im not too sure as to a specific solution.

 

I am using the YouTube API to read the authorized users videos into my application.

 

the function to display this is:

 

function echoVideoList($feed, $authenticated = false) 
{
    $table = '<table id="videoResultList" class="videoList"><tbody>';
    $results = 0;
    
    foreach ($feed as $entry) {
        $videoId = $entry->getVideoId();
        $thumbnailUrl = 'notfound.jpg';
        if (count($entry->mediaGroup->thumbnail) > 0) {
            $thumbnailUrl = $entry->mediaGroup->thumbnail[0]->url;
        }
    
        $videoTitle = $entry->mediaGroup->title;
        $videoDescription = $entry->mediaGroup->description;
        $videoCategoryArray = $entry->mediaGroup->category;
        $videoTags = $entry->mediaGroup->keywords;

        $table .= '<tr id="'. $videoId .'">'.
              '<td width="100%"><img onclick="ytVideoApp.presentVideo(\''. $videoId. '\')" src="'. $thumbnailUrl. '" /></td>'. 
              '<td>'. 
              '<a href="#" onclick="ytVideoApp.presentVideo(\''. $videoId. '\')">'. stripslashes($videoTitle) .'</a>';

          if ($authenticated) {
	  		
              $table .= '<p class="edit"><a onclick="ytVideoApp.presentMetaDataEditForm(\''. 
                  addslashes($videoTitle) .'\', \''. 
                  addslashes($videoDescription) .'\', \''. 
                  $videoCategoryArray . '\', \''. 
                  addslashes($videoTags) .'\', \'' . 
                  $videoId .'\');" href="#">edit video data</a> | <a href="#" onclick="ytVideoApp.confirmDeletion(\''. 
                  $videoId .'\');">delete this video</a></p><br clear="all">';
          }

    $table .= '</td></tr>';
    $results++;
    }

 

This is reading from youtube and displaying the users videos in a list with the video title and 'Edit|Delete' text.

 

I want to be able to display a grid of thumbnails instead of this. The thumbnails would then be displayed as a 3x3 table.

 

How can i echo the thumbnails into a grid like this?

 

any help with this is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/108358-youtube-thumbnails-to-a-grid/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.