I wanted to be able to display my most recent photos and videos in WordPress 2.5 for my new theme. I found that photos were easily taken care of by several plugins (I went with tan tan noodles Flickr plugin).

Videos, I’m afraid, were not so easy… I use ViddYou for my video uploads as I find it more personal, simple, friendly, and less garbage filled than YouTube. It also supports HD video if you are a professional member for a minimal annual fee. Anyway, I wanted to display the most recent viddyou activity on my footer-menu. I constructed a quick and dirty function to do this. All you need to do is replace the $feed URL with your personal user feed URL (simply substituting your username should work fine).

Enjoy and feel free to add any comments if you would like to see modifications or improvements or run into any bugs. I couldn’t get the Video ID as easily through Feedburner’s feeds so I just decided to stick with parsing ViddYou’s RSS feeds for now.

To-Do:

  1. Allow the plugin to support custom username, possibly custom image size for preview images
  2. Implement this method as a simple WP plugin
  3. Post the plugin to WordPress.org for easy sharing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
function recentVideos() {
  $feed = fetch_rss("http://www.viddyou.com/feed/user/_username_/feed.rss");
  $maxitems = 4;
  $items = array_slice($feed->items, 0, $maxitems);
  if(!empty($items)) {
      foreach ($items as $item) {
          /* parse the link portion of $item to get the video ID, and thusly our photo */
          $photoURL = parseViddYouPhotos($item['link']);
          $title = $item['title'];
?>
<a href="<?php echo $item['link']; ?>"><img src="<?php echo $photoURL; ?>" alt="<?php echo htmlentities($title); ?>" title="<?php echo htmlentities($title); ?>" /></a>
<?php
      } // end foreach
  } // end if
}
/*end recentVideos function */

function parseViddYouPhotos($link) {
  $parts = explode("=", $link);
  $photoId = $parts[1];
  return $photoURL = "http://www.viddyou.com/get/".$photoId.".medium.jpg";
}
/* end parseViddYouPhotos function */
?>

Comments