- if (! defined($im->Get("width")) || ! defined($im->Get("height"))) {
- return "[[img ".sprintf(gettext("failed to determine size of image %s"), $file)."]]";
+ if (exists $params{class}) {
+ $params{class}.=" img";
+ }
+ else {
+ $params{class}="img";
+ }
+
+ my $attrs='';
+ foreach my $attr (qw{alt title class id hspace vspace}) {
+ if (exists $params{$attr}) {
+ $attrs.=" $attr=\"$params{$attr}\"";
+ }
+ }
+
+ my $imgtag='<img src="'.$imgurl.
+ '" width="'.$dwidth.
+ '" height="'.$dheight.'"'.
+ $attrs.
+ (exists $params{align} && ! exists $params{caption} ? ' align="'.$params{align}.'"' : '').
+ ' />';
+
+ my $link;
+ if (! defined $params{link}) {
+ $link=$fileurl;
+ }
+ elsif ($params{link} =~ /^\w+:\/\//) {
+ $link=$params{link};
+ }
+
+ if (defined $link) {
+ $imgtag='<a href="'.$link.'">'.$imgtag.'</a>';
+ }
+ else {
+ my $b = bestlink($params{page}, $params{link});
+
+ if (length $b) {
+ add_depends($params{page}, $b, deptype("presence"));
+ $imgtag=htmllink($params{page}, $params{destpage},
+ $params{link}, linktext => $imgtag,
+ noimageinline => 1,
+ );
+ }