diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2010-01-07 15:36:49 -0500 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2010-01-07 15:36:49 -0500 |
commit | 253b1a41c1fec81e536840decfc9ea1645a41782 (patch) | |
tree | a51af7c347cb1f0a71beae3d2a7482ab3243348c /IkiWiki/Plugin | |
parent | e68cce6d1d51a513f54ab7d7e77e7c249aad3c06 (diff) | |
download | ikiwiki-253b1a41c1fec81e536840decfc9ea1645a41782.tar ikiwiki-253b1a41c1fec81e536840decfc9ea1645a41782.tar.gz |
refactor
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/img.pm | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 83f003629..845a4bf36 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -159,21 +159,20 @@ sub preprocess (@) { (exists $params{id} ? ' id="'.$params{id}.'"' : ''). ' />'; + my $alignclass=exists $params{align} ? "align-$params{align}" : ""; + + my $link; if (! defined $params{link} || lc($params{link}) eq 'yes') { - if (exists $params{caption} || !exists $params{align}) { - $imgtag='<a href="'.$fileurl.'">'.$imgtag.'</a>'; - } - else { - $imgtag='<a href="'.$fileurl.'" class="align-'.$params{align}.'">'.$imgtag.'</a>'; - } + $link=$fileurl; } elsif ($params{link} =~ /^\w+:\/\//) { - 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>'; - } + $link=$params{link}; + } + + if (defined $link) { + $imgtag='<a href="'.$link.'"'. + (!exists $params{caption} && $alignclass ? ' class="'.$alignclass.'"' : ''). + '>'.$imgtag.'</a>'; } else { my $b = bestlink($params{page}, $params{link}); @@ -183,14 +182,15 @@ sub preprocess (@) { $imgtag=htmllink($params{page}, $params{destpage}, $params{link}, linktext => $imgtag, noimageinline => 1, - (exists $params{caption} || !exists $params{align}) ? - () : (class => 'align-'.$params{align})); + (!exists $params{caption} && $alignclass) ? + (class => $alignclass) : (), + ); } } if (exists $params{caption}) { return '<table class="img'. - (exists $params{align} ? ' align-'.$params{align} : ''). + ($alignclass ? ' '.$alignclass : ''). '">'. '<caption>'.$params{caption}.'</caption>'. '<tr><td>'.$imgtag.'</td></tr>'. |