admin管理员组文章数量:1429552
I saw some other similar threads but they were all for YouTube videos. I was wondering if the same could be done for videos hosted on other servers like blip. Here is an example of a blip video:
This is how I currently have things set up:
I have a custom post type for Videos with a meta box for the src (video_src) from the embed code so all I have to do is enter the src and it gets displayed from my single-videos.php
template like this:
<embed src="<?=$video_src?>" type="application/x-shockwave-flash" width="400" height="200" allowscriptaccess="always" allowfullscreen="true" />
It would be awesome if somehow a frame of the video became the featured thumbnail of its post. Any idea on how something like this could be done?
I saw some other similar threads but they were all for YouTube videos. I was wondering if the same could be done for videos hosted on other servers like blip. Here is an example of a blip video: http://blip.tv/file/4778330
This is how I currently have things set up:
I have a custom post type for Videos with a meta box for the src (video_src) from the embed code so all I have to do is enter the src and it gets displayed from my single-videos.php
template like this:
<embed src="<?=$video_src?>" type="application/x-shockwave-flash" width="400" height="200" allowscriptaccess="always" allowfullscreen="true" />
It would be awesome if somehow a frame of the video became the featured thumbnail of its post. Any idea on how something like this could be done?
Share Improve this question edited Feb 22, 2011 at 11:17 Jan Fabry 30.5k4 gold badges90 silver badges136 bronze badges asked Feb 21, 2011 at 5:49 J82J82 2252 gold badges7 silver badges11 bronze badges4 Answers
Reset to default 3You can use the Blip TV API:
http://wiki.blip.tv/index.php/Blip.tv_API
Look for "How do I find the thumbnail for an item?" Examples of the API can be found in the wiki e.g. the PHP Example:
include_once("blipPHP.php");
$blipPHP = new blipPHP("username", "password");
$respond = $blipPHP->info(4794325);
returns a LONG array. Inside this you find:
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => alternate
[type] => application/rss+xml
[href] => http://blip.tv/rss/4812438
)
)
Now make a call to get http://blip.tv/rss/4812438 (you can check this one in your browser)
And you can parse the returned content for the thumnail as in the xpath expression given as you find:
<media:thumbnail url="http://a.images.blip.tv/Oldjewstellingjokes-AdrianeBergPastorFuzz165.jpg"/>
Now... maybe you have some questions:
1 how do i program something to get a url (URI) in a string?
WordPress provides a default method for that: wp_remote_get : READ: http://codex.wordpress/HTTP_API (see also http://core.trac.wordpress/ticket/4779)
2 Ok... now I have some website in a string what do i do with it?
Whatever you can think of, if it is stuff that is not "XML" related you will probably use smart regex to parse the content out of the string. (see php regex)
But.... to make stuff more readable for yourself, read the string in a DOM and then use XPath to quickly scan for the content. (see google:xpath or php: xpath)
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->strictErrorChecking = false;
if (!$dom->loadHTML($data))
{
foreach (libxml_get_errors() as $error)
{
// handle errors here
}
libxml_clear_errors();
}
else
{
$xpath = new DOMXPath($dom);
$elements = $xpath->query('/rss/channel/item/media:thumbnail/@url');
TADA! the thumbnail we found:
Bottom line is that there is probably no generic way to do it, because every service has its own API and methods and such.
If you want a more generic method, you could try oEmbed, which supports a thumbnail_url
property for videos. Many sites have oEmbed support built in, but oohEmbed or Embedly offer many more services through the same API.
For example, the oohEmbed request for your video returns the following information:
{
"type": "video",
"version": "1.0",
"title": "WEBISODE 14 - The Bay - Chapter 4 - Part 2",
"author_name": "TheBaytheSeries",
"author_url": "http://TheBaytheSeries.blip.tv",
"provider_name": "blip.tv",
"provider_url": "http://blip.tv",
"width": 720,
"height": 436,
"html": "<embed src=\"http://blip.tv/play/AYKk4RQC\" type=\"application/x-shockwave-flash\" width=\"720\" height=\"436\" allowscriptaccess=\"always\" allowfullscreen=\"true\"></embed>",
"thumbnail_url": "http://a.images.blip.tv/Thebaytheseries-WEBISODE14TheBayChapter4Part2721.png",
"thumbnail_width": 720,
"thumbnail_height": 436
}
It would seem that the thumbnail blip creates for each video isn't like youtube, where you can use the videoid to figure it out.
Here are two of your videos/thumbs from blip:
http://blip.tv/file/4778330 http://a.images.blip.tv/Thebaytheseries-WEBISODE14TheBayChapter4Part2721-711.jpg
http://blip.tv/file/4690791 http://a.images.blip.tv/Thebaytheseries-THEBAYTheSeriesSOMETHINGSADMusicVideoByTedKorsmo777-169.jpg
So it doesn't look possible.
本文标签: Getting a thumbnail for an external video as the thumbnail for a custom post type
版权声明:本文标题:Getting a thumbnail for an external video as the thumbnail for a custom post type? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745483481a2660279.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论