From: Giuseppe Bilotta Date: Tue, 5 Jan 2010 14:23:22 +0000 (+0100) Subject: Support align attribute for img with caption X-Git-Url: https://scripts.mit.edu/gitweb/www/ikiwiki.git/commitdiff_plain/4bda18a50aab714e72fce347cb4cff32316e55de?ds=inline 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. --- 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=''.$imgtag.''; + if (exists $params{caption} || !exists $params{align}) { + $imgtag=''.$imgtag.''; + } else { + $imgtag=''.$imgtag.''; + } } elsif ($params{link} =~ /^\w+:\/\//) { - $imgtag=''.$imgtag.''; + if (exists $params{caption} || !exists $params{align}) { + $imgtag=''.$imgtag.''; + } else { + $imgtag=''.$imgtag.''; + } } 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 ''. + return '
'. ''. ''. '
'.$params{caption}.'
'.$imgtag.'
'; diff --git a/doc/style.css b/doc/style.css index be86a0818..c56494fff 100644 --- a/doc/style.css +++ b/doc/style.css @@ -82,6 +82,26 @@ div.tags { text-align: center; } +.align-left { + float:left; +} + +.align-right { + float:right; +} + +.align-top { + vertical-align:top; +} + +.align-bottom { + vertical-align:bottom; +} + +.align-middle { + vertical-align:middle; +} + #backlinks { margin-top: 1em; }