From 253b1a41c1fec81e536840decfc9ea1645a41782 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 7 Jan 2010 15:36:49 -0500 Subject: [PATCH] refactor --- IkiWiki/Plugin/img.pm | 30 +++++++++++++++--------------- 1 file 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=''.$imgtag.''; - } - else { - $imgtag=''.$imgtag.''; - } + $link=$fileurl; } elsif ($params{link} =~ /^\w+:\/\//) { - if (exists $params{caption} || !exists $params{align}) { - $imgtag=''.$imgtag.''; - } - else { - $imgtag=''.$imgtag.''; - } + $link=$params{link}; + } + + if (defined $link) { + $imgtag=''.$imgtag.''; } 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 ''. ''. ''. -- 2.26.2
'.$params{caption}.'
'.$imgtag.'