OSDN Git Service

BugTrack/791: Fix typo 0,91 => 0.91
[pukiwiki/pukiwiki.git] / plugin / img.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: img.inc.php,v 1.13 2005/01/06 12:40:56 henoheno Exp $
4 //
5 // Inline-image plugin
6
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
9
10 // ²èÁü¤ò¥¤¥ó¥é¥¤¥óɽ¼¨
11 function plugin_img_convert()
12 {
13         $args = func_get_args();
14
15         // Check the 2nd argument first, for compatibility
16         $arg = isset($args[1]) ? strtoupper($args[1]) : '';
17         if ($arg == '' || $arg == 'L' || $arg == 'LEFT') {
18                 $align = 'left';
19         } else if ($arg == 'R' || $arg == 'RIGHT') {
20                 $align = 'right';
21         } else {
22                 // Stop word-wrapping only (Ugly but compatible)
23                 // Short usage: #img(,clear)
24                 return PLUGIN_IMG_CLEAR;
25         }
26
27         $url = isset($args[0]) ? $args[0] : '';
28         if (! is_url($url) || ! preg_match('/\.(jpe?g|gif|png)$/i', $url))
29                 return PLUGIN_IMG_USAGE;
30
31         $arg = isset($args[2]) ? strtoupper($args[2]) : '';
32         $clear = ($arg == 'C' || $arg == 'CLEAR') ? PLUGIN_IMG_CLEAR : '';
33
34         return <<<EOD
35 <div style="float:$align;padding:.5em 1.5em .5em 1.5em">
36  <img src="$url" alt="" />
37 </div>$clear
38 EOD;
39 }
40 ?>