Flickr Extension

This is a little Mediawiki Extension to include Flickr thumbnails. This example gets the X most interesting pictures (yes, Flickr really sorts like "sort"=>"interestingness-desc", by the users rating) for the tag you specify. You can use this to instantly put some related pictures on Wiki pages that dont have pictures yet. This is just a quick example, and can be heavily extended. Feel free to do so.

What you type:

Fnord

What you get:

Fnord

If you wish to just insert one photo, of your choice, then you require this Flickr extension : http://wiki.edsimpson.co.uk/index.php/Flickr_Extension (which requires no additional PEAR or phpFlickr libraries).

The -tag surrounds a keyword/Flickr Tag and optionally you can use limit to change the amount of thumbnails being shown, the maximum for tag-length is 255 chars and the maximum for limit is 10.

This is possible due to using a) the Flickr API, b) phpFlickr, c) the Debian PHP-Pear packages and d) a nice article in the latest iX (german) magazine, issue July 2006, p. 62 called "Bildergeflimmer". We could call this a Flickr->Mediawiki Mashup (->same iX issue, p. 55). mutante 20:56, 18 June 2006 (CEST)

Source
  Mediawiki MashUp Test (Web 2.3)
 * 2) mutante from http://s23.org/wiki
 * 3) inspired by "iX" magazine issue July 2006, p.62  article "Bildergeflimmer"
 * 4) greets: cosmea,took,DrOwl,Kunda,Finn,hundfred,kdoz... and all of S23

$wgExtensionFunctions[] = "wfFlickrExtension";


 * 1) extension hook callback function from mediawiki

function wfFlickrExtension { global $wgParser; $wgParser->setHook( "flickr", "renderFlickr" ); }

function renderFlickr( $input, $argv ) { global $wgOutputEncoding;

if (is_numeric($argv["limit"]) && is_int(intval($argv["limit"])) && $argv["limit"]>0 && $argv["limit"] <11) { $limit=intval($argv["limit"]); } else { $limit=3; }
 * 1) How many pictures to show, upper limit 10, if not good,set default to 3
 * 2) Make really sure the input is integer

$input = mysql_real_escape_string($input);
 * 1) What is the tag

if (!is_string($input) || strlen($input)>255) { $input="error"; } else { $tag=$input; }
 * 1) If not too long, set Input Text as Tag

require_once("./extensions/phpFlickr-2.0.0/phpFlickr.php");

$f = new phpFlickr(""); $f->enableCache("fs","./flickr_cache");

$photos_interesting = $f->photos_search(array("tags"=>"$tag", "sort"=>"interestingness-desc","per_page"=>$limit));
 * 1) get the X most interesting pictures for tag "flower"


 * 1) output a table with the pictures

$output=" "; } else { $output="Flickr Extension: no images found for tag $input"; } return $output; }

?> 