]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/img.pm
move userlink to IkiWiki.pm
[ikiwiki.git] / IkiWiki / Plugin / img.pm
index 14a32f63542fb827e40ff926771982436e02f59a..b6e7c9e41db20db9639ec7927a2994a0560a799e 100644 (file)
@@ -32,6 +32,11 @@ sub preprocess (@) { #{{{
        }
 
        push @{$links{$params{page}}}, $image;
+       # optimisation: detect scan mode, and avoid generating the image
+       if (! defined wantarray) {
+               return;
+       }
+
        my $file = bestlink($params{page}, $image);
 
        my $dir = $params{page};
@@ -106,9 +111,14 @@ sub preprocess (@) { #{{{
        if (! defined $params{link} || lc($params{link}) eq 'yes') {
                return  '<a href="'.$fileurl.'">'.$imgtag.'</a>';
        }
+       elsif ($params{link} =~ /^\w+:\/\//) {
+               return  '<a href="'.$params{link}.'">'.$imgtag.'</a>';
+       }
        elsif (length bestlink($params{page}, $params{link})) {
+               add_depends($params{page}, $params{link});
                return htmllink($params{page}, $params{destpage},
-                       $params{link}, linktext => $imgtag);
+                       $params{link}, linktext => $imgtag,
+                       noimageinline => 1);
        }
        else {
                return $imgtag;