X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/ec965fc92cd41f597c6e8e88584b9a688407c8c6..7ea1f9692687310fb434a7cc6e6f84b57b9f4ef8:/IkiWiki/Plugin/img.pm diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 78e378917..5f97e3810 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -44,6 +44,7 @@ sub preprocess (@) { } add_link($params{page}, $image); + # optimisation: detect scan mode, and avoid generating the image if (! defined wantarray) { return; @@ -65,8 +66,10 @@ sub preprocess (@) { my $r; if ($params{size} ne 'full') { + add_depends($params{page}, $image); + my ($w, $h) = ($params{size} =~ /^(\d*)x(\d*)$/); - error sprintf(gettext('bad size "%s"'), $params{size}) + error sprintf(gettext('wrong size format "%s" (should be WxH)'), $params{size}) unless (defined $w && defined $h && (length $w || length $h)); @@ -102,8 +105,6 @@ sub preprocess (@) { $imglink = $file; } - add_depends($imglink, $params{page}); - my ($fileurl, $imgurl); if (! $params{preview}) { $fileurl=urlto($file, $params{destpage}); @@ -134,11 +135,15 @@ sub preprocess (@) { elsif ($params{link} =~ /^\w+:\/\//) { $imgtag=''.$imgtag.''; } - elsif (length bestlink($params{page}, $params{link})) { - add_depends($params{page}, $params{link}); - $imgtag=htmllink($params{page}, $params{destpage}, - $params{link}, linktext => $imgtag, - noimageinline => 1); + else { + my $b = bestlink($params{page}, $params{link}); + + if (length $b) { + add_depends($params{page}, $b); + $imgtag=htmllink($params{page}, $params{destpage}, + $params{link}, linktext => $imgtag, + noimageinline => 1); + } } if (exists $params{caption}) {