Skip to content

Commit

Permalink
simple youtube image loader
Browse files Browse the repository at this point in the history
  • Loading branch information
pospi committed Apr 26, 2014
1 parent e6d2970 commit c5386bd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions imthumb-source-youtube.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Youtube thumbnail renderer wrapper
*
* @package ImThumb
* @author Sam Pospischil <[email protected]>
* @since 2014-04-26
*/

if (!class_exists('ImThumbSource_HTTP')) {
require_once(dirname(__FILE__) . '/imthumb-source-http.class.php');
}

class ImThumbSource_YouTube extends ImThumbSource_HTTP
{
public function readMetadata($src, ImThumb $requestor)
{
preg_match('/(\?|&)v=(\w+)(\W|$)/', $src, $matches);
$src = 'http://img.youtube.com/vi/' . $matches[2] . '/0.jpg';

return parent::readMetadata($src, $requestor);
}
}

0 comments on commit c5386bd

Please sign in to comment.