]> sipb.mit.edu Git - ikiwiki.git/commitdiff
the 100% correct way is to add it to %links on scan
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 23 May 2007 16:50:41 +0000 (16:50 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 23 May 2007 16:50:41 +0000 (16:50 +0000)
IkiWiki/Plugin/img.pm

index 7e167240e0770469025fe18055edf87084243296..0503f4097c336b1194e023231d87738238a0b6e2 100644 (file)
@@ -10,7 +10,7 @@ use IkiWiki 2.00;
 my %imgdefaults;
 
 sub import { #{{{
-       hook(type => "preprocess", id => "img", call => \&preprocess);
+       hook(type => "preprocess", id => "img", call => \&preprocess, scan => 1);
 } #}}}
 
 sub preprocess (@) { #{{{
@@ -31,17 +31,8 @@ sub preprocess (@) { #{{{
                return '';
        }
 
+       push @{$links{$params{page}}}, $image;
        my $file = bestlink($params{page}, $image);
-       if (! $file) {
-               # TODO: this may not be right, depending on where the file is
-               # created in the end
-               add_depends($params{page}, $image);
-
-               return "[[img ".sprintf(gettext("%s not found"), $image)."]]";
-       }
-       else {
-               add_depends($params{page}, $file);
-       }
 
        my $dir = IkiWiki::dirname($file);
        my $base = IkiWiki::basename($file);