2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: img.inc.php,v 1.14 2005/05/28 13:31:57 henoheno Exp $
7 define('PLUGIN_IMG_USAGE', '#img(): Usage: (URI-to-image[,right[,clear]])<br />' . "\n");
8 define('PLUGIN_IMG_CLEAR', '<div style="clear:both"></div>' . "\n"); // Stop word-wrapping
10 // Output inline-image tag from a URI
11 function plugin_img_convert()
13 if (PKWK_DISABLE_INLINE_IMAGE_FROM_URI)
14 return '#img(): PKWK_DISABLE_INLINE_IMAGE_FROM_URI prohibits this' .
17 $args = func_get_args();
19 // Check the 2nd argument first, for compatibility
20 $arg = isset($args[1]) ? strtoupper($args[1]) : '';
21 if ($arg == '' || $arg == 'L' || $arg == 'LEFT') {
23 } else if ($arg == 'R' || $arg == 'RIGHT') {
26 // Stop word-wrapping only (Ugly but compatible)
27 // Short usage: #img(,clear)
28 return PLUGIN_IMG_CLEAR;
31 $url = isset($args[0]) ? $args[0] : '';
32 if (! is_url($url) || ! preg_match('/\.(jpe?g|gif|png)$/i', $url))
33 return PLUGIN_IMG_USAGE;
35 $arg = isset($args[2]) ? strtoupper($args[2]) : '';
36 $clear = ($arg == 'C' || $arg == 'CLEAR') ? PLUGIN_IMG_CLEAR : '';
39 <div style="float:$align;padding:.5em 1.5em .5em 1.5em">
40 <img src="$url" alt="" />