Here is how you can get the YouTube Video ID from a URL no matter how many extra parameters get passed along with it.
function getYouTubeIdFromURL($url)
{
$url_string = parse_url($url, PHP_URL_QUERY);
parse_str($url_string, $args);
return isset($args['v']) ? $args['v'] : false;
}
Call it:
$youtube_id = getYouTubeIdFromURL("http://www.youtube.com/watch?v=jhjhkum-kq8&feature=related");
echo $youtube_id;
// jhjhkum-kq8
I’ve noticed in user’s code throughout the Facebook forum that they often display their FBML by having to echo the whole section or even worse closing the PHP tags, displaying the FBML and then reopening the PHP (example below)
if (!$session) {
$url=$facebook->getLoginUrl(array('canvas' => 1, 'fbconnect' => 0));
?>
<fb:redirect url="<?= $url ?>" />
<?php
exit;
}
So I thought I would write up a quick function to help this look a little cleaner.
I don’t recommend that you use this in all cases but it’s good to havehandy.
Read more »
After finding a bunch of ugly scripts to display files in a directory, I finally created my own. It’s two simple files: index.php and icons.png. (might switch to .gif soon) Grab the files at the address below and beautify your file listings.
Get it now at: http://www.halgatewood.com/free/file-directory-list/
I’ve also added a ‘freebies’ section to the lower right of the sidebar —–>
Check it out.
Read more »
Your doing some actually PHP in eZ Publish (in a module, class or whatever) and you need to find the image data for the Image Attribute of an object, here is what to do:
$node = eZContentObjectTreeNode::fetch( $node_id );
$dataMap = $node->dataMap();
$image_attribute = $dataMap['image'];
$image_array = $image_attribute->Content()->attribute('original');
$image_url = $image_array['url'];
- First get into the DataMap of your object or node.
- Change the ‘image’ of $dataMap['image'] to whatever the attribute_identifier of your image is.
- Change the ‘original’ of $image_pathobj->Content()->attribute(‘original‘); to whichever size of image you need to get. The image array contents all the good information of that image, i.e. height, width, filesize, etc.
- Use the ‘url’ to get a full path to your image. Slap a “/” on the front or use ezurl() to display.
If you want to see the available image sizes, you can check them by debugging this value:
$image_sizes = $image_attribute->Content()->attributes();
I recently built a subtitling system for a site that I am working on: khristos.org
It uses FlowPlayer with the built in Captions Plugin. The interesting part is that I also built an admin section where clients can add the subtitles on their own. Click the image below to see what it looks like. You can also check out the video here.

What’s also interesting is a Mashable article that explains how you can add Captions to your YouTube videos.
With the rising popularity of this subject and videos on the web, I figured it would be a good chance to give back to the community that has taken me so far.
Read more »