diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-01-05 15:23:22 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-01-06 21:02:09 +0100 |
commit | 4bda18a50aab714e72fce347cb4cff32316e55de (patch) | |
tree | b0c2f60054263d1bb2e011f9132b59d9945e1f75 /IkiWiki | |
parent | e22b1d05214ee90e7424f856dae43a35902950cf (diff) | |
download | ikiwiki-4bda18a50aab714e72fce347cb4cff32316e55de.tar ikiwiki-4bda18a50aab714e72fce347cb4cff32316e55de.tar.gz |
Support align attribute for img with caption
This is achieved by preparing CSS definitions that emulates the behavior
of the align attribute, and passing it to the outermost IMG wrapper
(A or TABLE) instead of passing the align value to IMG directly.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/img.pm | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 32023fa97..6f1919ea0 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -155,16 +155,23 @@ sub preprocess (@) { '" height="'.$dheight.'"'. (exists $params{alt} ? ' alt="'.$params{alt}.'"' : ''). (exists $params{title} ? ' title="'.$params{title}.'"' : ''). - (exists $params{align} ? ' align="'.$params{align}.'"' : ''). (exists $params{class} ? ' class="'.$params{class}.'"' : ''). (exists $params{id} ? ' id="'.$params{id}.'"' : ''). ' />'; if (! defined $params{link} || lc($params{link}) eq 'yes') { - $imgtag='<a href="'.$fileurl.'">'.$imgtag.'</a>'; + if (exists $params{caption} || !exists $params{align}) { + $imgtag='<a href="'.$fileurl.'">'.$imgtag.'</a>'; + } else { + $imgtag='<a href="'.$fileurl.'" class="align-'.$params{align}.'">'.$imgtag.'</a>'; + } } elsif ($params{link} =~ /^\w+:\/\//) { - $imgtag='<a href="'.$params{link}.'">'.$imgtag.'</a>'; + if (exists $params{caption} || !exists $params{align}) { + $imgtag='<a href="'.$params{link}.'">'.$imgtag.'</a>'; + } else { + $imgtag='<a href="'.$params{link}.'" class="align-'.$params{align}.'">'.$imgtag.'</a>'; + } } else { my $b = bestlink($params{page}, $params{link}); @@ -173,12 +180,16 @@ sub preprocess (@) { add_depends($params{page}, $b, deptype("presence")); $imgtag=htmllink($params{page}, $params{destpage}, $params{link}, linktext => $imgtag, - noimageinline => 1); + noimageinline => 1, + (exists $params{caption} || !exists $params{align}) ? + () : (class => 'align-'.$params{align})); } } if (exists $params{caption}) { - return '<table class="img">'. + return '<table class="img'. + (exists $params{align} ? ' align-'.$params{align} : ''). + '">'. '<caption>'.$params{caption}.'</caption>'. '<tr><td>'.$imgtag.'</td></tr>'. '</table>'; |