- if (! defined($im->Get("width")) || ! defined($im->Get("height"))) {
- return "[[img ".sprintf(gettext("failed to determine size of image %s"), $file)."]]";
+ my $imgtag='<img src="'.$imgurl.
+ '" width="'.$dwidth.
+ '" height="'.$dheight.'"'.
+ (exists $params{alt} ? ' alt="'.$params{alt}.'"' : '').
+ (exists $params{title} ? ' title="'.$params{title}.'"' : '').
+ (exists $params{align} ? ' align="'.$params{align}.'"' : '').
+ (exists $params{class} ? ' class="'.$params{class}.'"' : '').
+ (exists $params{id} ? ' id="'.$params{id}.'"' : '').
+ ' />';
+
+ if (! defined $params{link} || lc($params{link}) eq 'yes') {
+ $imgtag='<a href="'.$fileurl.'">'.$imgtag.'</a>';
+ }
+ elsif ($params{link} =~ /^\w+:\/\//) {
+ $imgtag='<a href="'.$params{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);
+ }