Latest Video

A useful snippet was provided by Dawa (http://drupal.org/user/136967) for the Video module. The image-attach portion of that module allows you to upload a thumbnail for a video, but the built-in block for "latest videos" only provide the video's title.

The link to the post is here: http://drupal.org/node/137560

The PHP code provided by Dawa, which will list the latest 5 examples, is as follows:

<?php
$result
= db_query("SELECT n.nid, n.title, n.created, v.vid, v.serialized_data FROM {node} n INNER JOIN {video} v ON n.vid = v.vid WHERE n.type = 'video' AND n.status = 1 ORDER BY n.created DESC");

for (
$i = 1; $i <= 5; $i++) {

  
$node = db_fetch_object($result);
  
$video = video_load($node);
  
$image = node_load(array('nid'=>$video->serial_data['iid']));    
  
$video->iid = $video->serial_data['iid'] = $image->nid;

  if (
$video->iid) {
     
$output = theme('video_image_teaser', $video);
     
$output .= l($node->title, "node/$node->nid", array(), NULL, NULL, FALSE, TRUE);
      print
$output . "<br>";
  }

}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.