]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/img.pm
Split trail directive into trailitems, trailoptions
[ikiwiki.git] / IkiWiki / Plugin / img.pm
index 2375ead8968b6a9baf64ff8ac825dbde6a75b82d..b98e843d436b1aed68ca13a12da94ee44a74dd06 100644 (file)
@@ -64,10 +64,11 @@ sub preprocess (@) {
 
        my $dir = $params{page};
        my $base = IkiWiki::basename($file);
+       my $issvg = $base=~s/\.svg$/.png/i;
 
        eval q{use Image::Magick};
        error gettext("Image::Magick is not installed") if $@;
-       my $im = Image::Magick->new;
+       my $im = Image::Magick->new($issvg ? (magick => "png") : ());
        my $imglink;
        my $r = $im->Read($srcfile);
        error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r;
@@ -152,14 +153,11 @@ sub preprocess (@) {
                $imgurl=urlto($imglink, $params{destpage});
        }
        else {
-               $fileurl="$config{url}/$file";
-               $imgurl="$config{url}/$imglink";
+               $fileurl=urlto($file);
+               $imgurl=urlto($imglink);
        }
 
-       if (exists $params{class}) {
-               $params{class}.=" img";
-       }
-       else {
+       if (! exists $params{class}) {
                $params{class}="img";
        }