WordPress Plugin für TED Filme

Sun, 01. Mar 2009

Categories: de sysadmin Tags: Plugin TED

Basierend auf dem Plugin von Robert Anselm experimentiere ich nachdem TED den ‘embed’ Code geändert hat derzeit mit folgendem Plugin Code:

 1<?php
 2/*
 3Plugin Name: TEDTalks for WordPress
 4Plugin URI: http://www.robertanselm.com/2.0/
 5Description: A filter for WordPress that displays TED.com videos based on the
 6Youtube WordPress plugin by Joern Zaefferer. Copy and paste the TEDTalks
 7"Embed Video" code to a text editor and look for the .flv filename of the
 8flashvideo. (eg.: JOHNMAEDA-2007_high.flv ).
 9In WordPress type: [TEDTALKS JOHNMAEDA-2007_high.flv].
10Version: 1.0
11Author: Robert Anselm
12Author URI: http://www.robertanselm.com/2.0/
13
14Instructions
15
16Copy this file you unzipped into the wp-content/plugins folder of WordPress,
17then go to Administration > Plugins, it should be in the list. Activtate it
18and every occurence of the expression [TEDTALKS file] will as
19an embedded flash player. Replace "file" with the TEDTALKS .flv filename.
20Copy and paste the TEDTalks "Embed Viedo" code to a text editor and look
21for the .flv filename of the flashvideo. (eg.: JOHNMAEDA-2007_high.flv ).
22In WordPress type: [TEDTALKS JOHNMAEDA-2007_high.flv].
23
24See also the player embed swap at TED:
25 http://blog.TED.com/2009/01/TEDtalks_time_f.php
26 http://blog.TED.com/2009/01/TEDtalks_embed_1.php
27*/
28
29define("TEDTALKS_REGEXP", "/\[TEDTALKS ([[:print:]]+)[-_: ]([0-9]{4}[GP]?)\]/");
30define("TEDTALKS_TARGET", "<object width='446' height='326'><param name='movie' value='http://video.TED.com/assets/player/swf/EmbedPlayer.swf'></param><param name='allowFullScreen' value='true' /><param name='wmode' value='transparent'></param><param name='bgColor' value='#ffffff'></param> <param name='flashvars' value='vu=http://video.TED.com/talks/embed/###TED_###-embed_high.flv&su=http://images.TED.com/images/TED/TEDindex/embed-posters/###TED-###.embed_thumbnail.jpg&vw=432&vh=240&ap=0&ti=462' /><embed src='http://video.TED.com/assets/player/swf/EmbedPlayer.swf' pluginspace='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='transparent' bgColor='#ffffff' width='446' height='326' allowFullScreen='true' flashvars='vu=http://video.TED.com/talks/embed/###TED_###-embed_high.flv&su=http://images.TED.com/images/TED/TEDindex/embed-posters/###TED-###.embed_thumbnail.jpg&vw=432&vh=240&ap=0&ti=462'></embed></object>");
31
32function TEDtalks_plugin_callback($match)
33{
34  $output = TEDTALKS_TARGET;
35  $speaker = $match[1];
36  $year = $match[2];
37  $output = str_replace("###TED-###", $speaker.'-'.$year, $output);
38  $output = str_replace("###TED_###", $speaker.'_'.$year, $output);
39  //if(strlen($year) > 4)
40  if('P'==substr($year,4))
41    $output = str_replace("-embed_high.flv", "-embed-PARTNER_high.flv", $output);
42  return ($output);
43}
44
45function TEDtalks_plugin($content)
46{
47  return (preg_replace_callback(TEDTALKS_REGEXP, 'TEDtalks_plugin_callback', $content));
48}
49
50add_filter('the_content', 'TEDtalks_plugin');
51add_filter('comment_text', 'TEDtalks_plugin');
52
53?>

Das Plugin ist ein wenig komplizierter zu erklären, aber einfacher zu benutzen (Magic!).