]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/img.pm
* table: Text::CSV doesn't return decoded unicode (XS module); decode its
[ikiwiki.git] / IkiWiki / Plugin / img.pm
index b1c9db80c969055edc59227b5c79d83945b7b911..c4e4a6f220beae57c19c239db73fa1ee624cd678 100644 (file)
@@ -62,7 +62,7 @@ sub preprocess (@) { #{{{
                        return "[[img ".sprintf(gettext("failed to read %s: %s"), $file, $r)."]]" if $r;
 
                        $r = $im->Resize(geometry => "${w}x${h}");
-                       return "[[img ".sprinftf(gettext("failed to resize: %s"), $r)."]]" if $r;
+                       return "[[img ".sprintf(gettext("failed to resize: %s"), $r)."]]" if $r;
 
                        # don't actually write file in preview mode
                        if (! $params{preview}) {
@@ -96,9 +96,19 @@ sub preprocess (@) { #{{{
                return "[[img ".sprintf(gettext("failed to determine size of image %s"), $file)."]]";
        }
 
-       return '<a href="'.$fileurl.'"><img src="'.$imgurl.
+       my $imgtag='<img src="'.$imgurl.
                '" alt="'.$alt.'" width="'.$im->Get("width").
-               '" height="'.$im->Get("height").'" /></a>';
+               '" height="'.$im->Get("height").'"'.
+               (exists $params{class} ? ' class="'.$params{class}.'"' : '').
+               (exists $params{id} ? ' id="'.$params{id}.'"' : '').
+               ' />';
+
+       if (! defined $params{link} || lc($params{link}) eq 'yes') {
+               return  '<a href="'.$fileurl.'">'.$imgtag.'</a>';
+       }
+       else {
+               return $imgtag;
+       }
 } #}}}
 
 1