Create a new article
Write your page title here:
We currently have 3,185 articles on s23. Type your article name above or click on one of the titles below and start writing!


Flickr Extension

Revision as of 12:21, 22 June 2006 by imported>mutante

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:


What you get:


What you type:

<flickr limit=5>Fnord</flickr>

What you get:

<flickr limit=5>Fnord</flickr>

The <flickr>-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)


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

$wgExtensionFunctions[] = "wfFlickrExtension";

# extension hook callback function from mediawiki

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

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

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

# What is the tag
$input = mysql_escape_string($input);

# If not too long, set Input Text as Tag
if (!is_string($input) || strlen($input)>255) {
} else {


$f = new phpFlickr("<your Flickr API key here>");

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

# output a table with the pictures

$output="<table><tr><td colspan='$limit'>The $limit most interesting photos from Flickr for the tag <b>'$tag'</b></td></tr><t$
if (is_array ($photos_interesting['photo']) && count($photos_interesting['photo'])>0) {
foreach ($photos_interesting['photo'] as $photo) {
$output.="<td><img border='0' alt='$photo[title]' " . " src=". $f->buildPhotoURL($photo, "Square") . "></td>";
} else {
$output="<i>Flickr Extension: no images found for tag <b>$input</b></i>";
return $output;

Cookies help us deliver our services. By using our services, you agree to our use of cookies.