]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/img.pm
* Correct bug in the img plugin that caused dependencies on images to not
[ikiwiki.git] / IkiWiki / Plugin / img.pm
index 7226231a05bd74f01aeeebed3293e60ada885e28..7e167240e0770469025fe18055edf87084243296 100644 (file)
@@ -31,9 +31,17 @@ sub preprocess (@) { #{{{
                return '';
        }
 
-       add_depends($params{page}, $image);
-       my $file = bestlink($params{page}, $image)
-               || return "[[img ".sprintf(gettext("%s not found"), $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);
@@ -93,6 +101,10 @@ sub preprocess (@) { #{{{
                $imgurl="$config{url}/$imglink";
        }
 
+       if (! defined($im->Get("width")) || ! defined($im->Get("height"))) {
+               return "[[img ".sprintf(gettext("failed to determine size of image %s"), $file)."]]";
+       }
+
        return '<a href="'.$fileurl.'"><img src="'.$imgurl.
                '" alt="'.$alt.'" width="'.$im->Get("width").
                '" height="'.$im->Get("height").'" /></a>';