diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-06-07 23:45:40 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-06-07 23:45:40 -0400 |
commit | f6b47b0d1c67228f13242864a50827b40abb320c (patch) | |
tree | b825d44967a245c6fc03bfacb882ed1a18769e61 /IkiWiki | |
parent | d258793c3f56dd71a5f39d87145b5c198ba8af4f (diff) |
img: Support captions.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/img.pm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index abc7e099a..c4e0fdd89 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -23,12 +23,14 @@ sub preprocess (@) { #{{{ my $size = $params{size} || $imgdefaults{$params{page}}->{size} || 'full'; my $alt = $params{alt} || $imgdefaults{$params{page}}->{alt} || ''; my $title = $params{title} || $imgdefaults{$params{page}}->{title} || ''; + my $caption = $params{caption} || $imgdefaults{$params{page}}->{caption} || ''; if ($image eq 'defaults') { $imgdefaults{$params{page}} = { size => $size, alt => $alt, title => $title, + caption => $caption, }; return ''; } @@ -112,17 +114,24 @@ sub preprocess (@) { #{{{ ' />'; if (! defined $params{link} || lc($params{link}) eq 'yes') { - return '<a href="'.$fileurl.'">'.$imgtag.'</a>'; + $imgtag='<a href="'.$fileurl.'">'.$imgtag.'</a>'; } elsif ($params{link} =~ /^\w+:\/\//) { - return '<a href="'.$params{link}.'">'.$imgtag.'</a>'; + $imgtag='<a href="'.$params{link}.'">'.$imgtag.'</a>'; } elsif (length bestlink($params{page}, $params{link})) { add_depends($params{page}, $params{link}); - return htmllink($params{page}, $params{destpage}, + $imgtag=htmllink($params{page}, $params{destpage}, $params{link}, linktext => $imgtag, noimageinline => 1); } + + if (defined $caption) { + return '<table class="img">'. + '<caption>'.$caption.'</caption>'. + '<tr><td>'.$imgtag.'</td></tr>'. + '</table>'; + } else { return $imgtag; } |