X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/ee1ad53c4c2710aa7ded61bdc56f3a8cce514f22..9e885694cee6ab0e1244dba321b0471f0af71d29:/IkiWiki/Plugin/img.pm diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 7226231a0..7e167240e 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -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 ''.$alt.'';