? image_filter.module.patch
Index: image_filter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image_filter/image_filter.module,v
retrieving revision 1.17
diff -u -r1.17 image_filter.module
--- image_filter.module	20 May 2005 17:57:20 -0000	1.17
+++ image_filter.module	7 Oct 2005 03:39:40 -0000
@@ -10,10 +10,11 @@
 function image_filter_long_tip_translated() {
   return t(
 '<p>You may quickly link to image nodes using a special syntax. Each image code will be replaced by thumbnail linked to full size image node. Syntax:</p>
-<blockquote><code>[image:<em>node_id</em> align=<em>alignment</em> hspace=<em>n</em> vspace=<em>n</em> border=<em>n</em> size=<em>label</em> width=<em>n</em> height=<em>n</em> nolink=(0|1) class=<em>name</em> style=<em>style-data</em>]</code></blockquote>
+<blockquote><code>[image:<em>node_id</em> align=<em>alignment</em> hspace=<em>n</em> vspace=<em>n</em> border=<em>n</em> size=<em>label</em> width=<em>n</em> height=<em>n</em> nolink=(0|1) class=<em>name</em> style=<em>style-data</em> node=<em>id</em>]</code></blockquote>
 <p>Every parameter except <em>node_id</em> is optional.</p>
 <p>Typically, you will specify one of <code>size</code>, <code>width</code>, or <code>height</code>, or none of them. If you use <code>size=<em>label</em></code>, where <em>label</em> is one of the image size labels specified on the image settings page, the size associated with that label will be used. The sizes "thumbnail", "preview", and "original" are always available. If you use <code>width=<em>n</em></code> or <code>height=<em>n</em></code>, the image will be scaled to fit the specified width or height. If you use none of them, the thumbnail image size will be used.</p>
-<p>If you specify <code>nolink=1</code>, no link will be created to the image node. The default is to create a link.</p>
+<p>If you specify <code>nolink=1</code>, no link will be created to the image node. The default is to create a link to the image.</p>
+<p>Alternatively, if you specify <code>node=id</code>, a link will be created to the node with the given id.</p>
 <p>The <code>align</code>, <code>hspace</code>, <code>vspace</code>, <code>border</code>, <code>class</code>, and <code>style</code> parameters set the corresponding attributes in the generated <code>img</code> tag.</p>');
 }
 
@@ -109,7 +110,7 @@
       $args['border'] = image_filter_attr_value($a[3], IMAGE_FILTER_INTEGER);
     }
     else {
-      // New syntax: [image:node_id (left|right|top|middle|bottom|absmiddle|texttop|baseline|align=alignment) hspace=n vspace=n border=n size=label width=n height=n nolink=(0|1) class=name style=style-data]
+      // New syntax: [image:node_id (left|right|top|middle|bottom|absmiddle|texttop|baseline|align=alignment) hspace=n vspace=n border=n size=label width=n height=n nolink=(0|1) class=name style=style-data node=id]
 
       // Convert bare alignment 'X' to 'align="X"'.
       $match[3] = preg_replace("/^(left|right|top|middle|bottom|absmiddle|texttop|baseline)\b/i",
@@ -176,7 +177,19 @@
       $img->border = image_filter_attr_value($args['border'], IMAGE_FILTER_INTEGER);
       $img->class = image_filter_attr_value($args['class'], IMAGE_FILTER_WORD);
       $img->style = image_filter_attr_value($args['style'], IMAGE_FILTER_STRING);
-      $img->link = ($args['nolink'] ? NULL : "node/$img->nid");
+      if( $args['nolink'] ) {
+      	$img->link = NULL;
+      }
+      else {
+      	// See if we have a link target node specified
+      	$linkid = image_filter_attr_value($args['node'], IMAGE_FILTER_INTEGER);
+      	if( $linkid ) {
+      	  $img->link = "node/$linkid";
+      	}
+      	else {
+          $img->link = "node/$img->nid";
+      	}
+      }
 
       $img_tag = theme("image_inline_img", $img);
       $text = str_replace($match[0], $img_tag, $text);
