2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: img.inc.php,v 1.15 2007/04/08 10:22:18 henoheno Exp $
4 // Copyright (C) 2002-2005, 2007 PukiWiki Developers Team
5 // License: GPL v2 or (at your option) any later version
7 // Inline-image plugin (Output inline-image tag from a URI)
9 define('PLUGIN_IMG_USAGE', '#img(): Usage: (URI-to-image[,right[,clear]])<br />' . "\n");
10 define('PLUGIN_IMG_CLEAR', '<div style="clear:both"></div>' . "\n"); // Stop word-wrapping
12 function plugin_img_convert()
14 if (PKWK_DISABLE_INLINE_IMAGE_FROM_URI)
15 return '#img(): PKWK_DISABLE_INLINE_IMAGE_FROM_URI prohibits this' .
18 $args = func_get_args();
20 // Check the 2nd argument first, for compatibility
21 $arg = isset($args[1]) ? strtoupper($args[1]) : '';
22 if ($arg == '' || $arg == 'L' || $arg == 'LEFT') {
24 } else if ($arg == 'R' || $arg == 'RIGHT') {
27 // Stop word-wrapping only (Ugly but compatible)
28 // Short usage: #img(,clear)
29 return PLUGIN_IMG_CLEAR;
32 $url = isset($args[0]) ? $args[0] : '';
33 if (! is_url($url) || ! preg_match('/\.(jpe?g|gif|png)$/i', $url))
34 return PLUGIN_IMG_USAGE;
36 $arg = isset($args[2]) ? strtoupper($args[2]) : '';
37 $clear = ($arg == 'C' || $arg == 'CLEAR') ? PLUGIN_IMG_CLEAR : '';
40 <div style="float:$align;padding:.5em 1.5em .5em 1.5em">
41 <img src="$url" alt="" />