From: Buzz <bu...@os...> - 2006-05-10 06:24:12
|
Hi guys, I'm new to the list (and to phpWiki.. just 3 days), but I thought I'd contribute a plugin I've just written. PROBLEM: Everywhere that a thumbnail is put in my HTML pages, I always make it click-able, so that you can see the "full-sized" version of the image easily. I couldn't figure out what combination of wiki syntax would give me a <img> tag inside a <a> tag. Ie: like <a href='...'><img src='...'></a> So I wrote a plugin that does it: <?plugin ImageThumb src="/files/thumbnail1.jpg" target="/files/fullsize1.jpg" ?> This gives you the thumbnail (in 'src') just as usual, but it's clickable, and links to the URL from 'target'. Hope this is useful to someone... And if the developers want to included this in the core of PhPWiki, go wild. Buzz. SOLUTION: ImageThumb.php --------------cut here:------------------- <?php // -*-php-*- /** Copyright 2006 David Bussenschutt, based on HelloWord code template which is Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam * released under the same license as PhpWiki. * great work guys! This file is NOT YET part of PhpWiki. */ /** * Display a thumbnail of an image, and make it a clickable link to the fullsized version. ( I can't believe you can't already do this in Wiki Syntax!) * * Usage: * <?plugin ImageThumb src="/files/thumbnail1.jpg" target="/files/fullsize1.jpg" ?> */ // Constants are defined before the class. if (!defined('THE_END')) define('THE_END', "!"); class WikiPlugin_ImageThumb extends WikiPlugin { // Five required functions in a WikiPlugin. function getName () { return _("ImageThumb"); } function getDescription () { return _("Link from an image Plugin"); } function getVersion() { return preg_replace("/[Revision: $]/", '', "\$Revision: 1.00 $"); } // Establish default values for each of this plugin's arguments. function getDefaultArguments() { return array('src' => "wiki/themes/default/images/poweredby_phpwiki_51x31.png", 'target' => "wiki/themes/default/images/poweredby_phpwiki_82x31.png"); } function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); $html = HTML::a(array('href' => $target, 'class' => '', 'title' => $src), HTML::img(array('src'=>$src)) ); return $html; } }; ?> |