? patch
Index: teaserthumbnail.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/teaserthumbnail/teaserthumbnail.module,v
retrieving revision 1.5
diff -u -p -r1.5 teaserthumbnail.module
--- teaserthumbnail.module	14 Feb 2009 04:51:09 -0000	1.5
+++ teaserthumbnail.module	16 Dec 2009 04:56:37 -0000
@@ -286,18 +286,41 @@ function _teaserthumbnail_delete_thumb($
  * relative path).
  */
 function _teaserthumbnail_get_local_images($text) {
-  $pattern  = "/<img[^>]+src=\"([^\"]+)/i";
-  $matches = array();
+  //completly rewritten by tech-o-matic
+  global $base_url;
+  
+  $images = array();
+  preg_match_all("/(img|src)=(\"|')[^\"'>]+/i", $text, $media);
+  //preg_match_all('/<img.*?src="(.+?)"(.*?)>/i', $text, $media);
+  
+  unset($data);
+  $data = preg_replace("/(img|src)(\"|'|=\"|=')(.*)/i","$3", $media[0]);
+  	
+  foreach($data as $url)
+  {
+  	
+    $info = pathinfo($url);
+	if (isset($info['extension']))
+	{
+		if ((strcasecmp($info['extension'], 'jpg') == 0) ||
+		(strcasecmp($info['extension'], 'jpeg') == 0) ||
+		(strcasecmp($info['extension'], 'gif') == 0) ||
+		(strcasecmp($info['extension'], 'png') == 0))
+		array_push($images, $url);
+	}
+  }
+
   $local_pics = array();
-  if (preg_match_all($pattern, $text, $matches)) {
-    foreach ($matches[1] as $url) {
-      // If it is a local file (i.e. src is a relative path)
-      if ($url != '' && !strstr($url, 'mailto:') && $url[0] != '#' && !strstr($url, '://')) {
-        $local_pics[] = $url;
-      }
-      // TODO : deal with absolute paths (http://www.mysite.com/...)
-    }
+  foreach($images as $url){
+  	if ($url != ''
+  	 && !strstr($url, 'mailto:')
+  	 && $url[0] != '#'
+  	 && (!strstr($url, '://') || strstr($url, $base_url))
+  	 ) {
+  		$local_pics[] = $url;
+	}
   }
+  
   return $local_pics;
 }
 
@@ -343,6 +366,7 @@ function _teaserthumbnail_get_thumbnail_
  */
 function _teaserthumbnail_process(&$node, $field) {
   $teaser_prefix = '';
+  global $base_url;
   
   // We retrieve the local pictures
   $local_pics = _teaserthumbnail_get_local_images($field);
@@ -361,20 +385,22 @@ function _teaserthumbnail_process(&$node
     $i = 0;
     do {
       // We ensure we have a relative path (we remove the base path from the beginning of the path)
-      $pattern = "/^". str_replace('/', '\/', base_path()) ."(.*)$/";
-      $relative_path = preg_replace($pattern, "$1", $local_pics[$i]);
+      $relative_path = $local_pics[$i];
+      //changed by tech-o-matic
+      if(substr( $relative_path, 0, strlen($base_url.'/')) == $base_url.'/'){
+      	$relative_path = substr($relative_path, strlen($base_url.'/'));
+      }elseif(substr( $relative_path, 0, strlen(base_path())) == base_path()){
+      	$relative_path = substr($relative_path, strlen(base_path()));
+      }
       
-      if (file_exists($relative_path)) {
-        // We check that it is a picture
-        $image_info = image_get_info($relative_path);
-        
-        // We want a picture with a valid extension
-        if ($image_info && isset($image_info['extension'])) {
-          // We check for minimum width and height
-          if (($image_info['width'] >= $min_width) && ($image_info['height'] >= $min_height)) {
-            _teaserthumbnail_save_thumb($node, $relative_path, $relative_path);
-            return;
-          }
+      // We check that it is a picture
+      $image_info = image_get_info($relative_path);
+      // We want a picture with a valid extension
+      if ($image_info && isset($image_info['extension'])) {
+        // We check for minimum width and height
+        if (($image_info['width'] >= $min_width) && ($image_info['height'] >= $min_height)) {
+          _teaserthumbnail_save_thumb($node, $relative_path, $relative_path);
+          return;
         }
       }
       $i ++;
@@ -389,6 +415,8 @@ function _teaserthumbnail_process(&$node
  * Save a reference to the picture selected to build the thumbnail in the db.
  */
 function _teaserthumbnail_save_thumb($node, $filepath) {
+  watchdog('tt_save', 'save:'.$filepath, array(),WATCHDOG_WARNING);
+        
   $num_rows = db_result(db_query("SELECT count(*) FROM {teaserthumbnail} WHERE nid = %d", $node->nid));
   if ($num_rows) {
     db_query("UPDATE {teaserthumbnail} SET filepath = '%s' WHERE nid = %d", $filepath, $node->nid);
