--- loncom/xml/londefdef.pm	2002/01/18 16:33:54	1.41
+++ loncom/xml/londefdef.pm	2002/02/21 04:29:27	1.43
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.41 2002/01/18 16:33:54 sakharuk Exp $
+# $Id: londefdef.pm,v 1.43 2002/02/21 04:29:27 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1331,17 +1331,35 @@ EDITBUTTON
             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
                                         $token->[2]->{'src'};
             my $currentstring = '';
-            if ($target eq 'web') {
+	    if ($target eq 'web') {
               $currentstring = $token->[4];     
 	    } elsif ($target eq 'tex') {
-                my $durty = $token->[2]->{'src'};
-                $durty =~ s!(^.*)/(.*)$!$1/!;
-                my $durtytwo = $2;
-                my $num = index($durtytwo,'gif',0);
-		substr($durtytwo,$num,3) = 'eps';
-		$currentstring = '\graphicspath{{/home/httpd/html'.$durty.'}}\fbox{\includegraphics{'.$durtytwo.'}}';
-	    } 
-	   return $currentstring;
+	      my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
+	      my $file;
+	      my $path;
+              if ($src =~ m!(.*)/([^/]*)$!) {
+		$file = $2;
+		$path = $1;
+		if ($path=~m:^/:) {
+		  $path = '/home/httpd/html'.$path;
+		} elsif ($path =~ /^\./) {
+		  $path = $Apache::lonxml::pwd[-1].'/'.$path;
+		} else {
+		  #else it is a full url don't print
+		  $path = undef;
+		}
+	      } else {
+		$path = $Apache::lonxml::pwd[-1];
+		$file = $src;
+	      }
+	      $file=~s/(\.gif|\.jpg)$/\.eps/;
+	      if ($path) {
+		$currentstring = '\graphicspath{{'.$path.'}}\fbox{\includegraphics{'.$file.'}}';
+	      } else {
+		$currentstring = 'See the image at \tt{'.$src.'}';
+	      }
+	    }
+	    return $currentstring;
 	}
         sub end_img {
 	    my ($target,$token) = @_;