twitPic no longer exists/is active
This commit is contained in:
parent
092dfee1c6
commit
f5efbd8037
|
@ -48,7 +48,6 @@ class oEmbedHelper
|
||||||
'vimeo.com' => 'https://vimeo.com/api/oembed.json',
|
'vimeo.com' => 'https://vimeo.com/api/oembed.json',
|
||||||
);
|
);
|
||||||
protected static $functionMap = array(
|
protected static $functionMap = array(
|
||||||
'twitpic.com' => 'oEmbedHelper::twitPic',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -250,51 +249,6 @@ class oEmbedHelper
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Using a local function for twitpic lookups, as oohembed's adapter
|
|
||||||
* doesn't return a valid result:
|
|
||||||
* http://code.google.com/p/oohembed/issues/detail?id=19
|
|
||||||
*
|
|
||||||
* This code fetches metadata from Twitpic's own API, and attempts
|
|
||||||
* to guess proper thumbnail size from the original's size.
|
|
||||||
*
|
|
||||||
* @todo respect maxwidth and maxheight params
|
|
||||||
*
|
|
||||||
* @param string $url
|
|
||||||
* @param array $params
|
|
||||||
* @return object
|
|
||||||
*/
|
|
||||||
static function twitPic($url, $params=array())
|
|
||||||
{
|
|
||||||
$matches = array();
|
|
||||||
if (preg_match('!twitpic\.com/(\w+)!', $url, $matches)) {
|
|
||||||
$id = $matches[1];
|
|
||||||
} else {
|
|
||||||
throw new Exception("Invalid twitpic URL");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab metadata from twitpic's API...
|
|
||||||
// http://dev.twitpic.com/docs/2/media_show
|
|
||||||
$data = self::json('http://api.twitpic.com/2/media/show.json',
|
|
||||||
array('id' => $id));
|
|
||||||
$oembed = (object)array('type' => 'photo',
|
|
||||||
'url' => 'http://twitpic.com/show/full/' . $data->short_id,
|
|
||||||
'width' => $data->width,
|
|
||||||
'height' => $data->height);
|
|
||||||
if (!empty($data->message)) {
|
|
||||||
$oembed->title = $data->message;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thumbnail is cropped and scaled to 150x150 box:
|
|
||||||
// http://dev.twitpic.com/docs/thumbnails/
|
|
||||||
$thumbSize = 150;
|
|
||||||
$oembed->thumbnail_url = 'http://twitpic.com/show/thumb/' . $data->short_id;
|
|
||||||
$oembed->thumbnail_width = $thumbSize;
|
|
||||||
$oembed->thumbnail_height = $thumbSize;
|
|
||||||
|
|
||||||
return $oembed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch some URL and return JSON data.
|
* Fetch some URL and return JSON data.
|
||||||
*
|
*
|
||||||
|
|
|
@ -98,9 +98,7 @@ class oEmbedTest extends PHPUnit_Framework_TestCase
|
||||||
static public function knownSources()
|
static public function knownSources()
|
||||||
{
|
{
|
||||||
$sources = array(
|
$sources = array(
|
||||||
array('http://www.flickr.com/photos/brionv/5172500179/', 'photo'),
|
array('https://www.flickr.com/photos/brionv/5172500179/', 'photo'),
|
||||||
array('http://yfrog.com/fy42747177j', 'photo'),
|
|
||||||
array('http://twitpic.com/36adw6', 'photo'),
|
|
||||||
);
|
);
|
||||||
return $sources;
|
return $sources;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user